<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="js,题库," />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="1&amp;#x3001;javascript &amp;#x7684; typeof &amp;#x8FD4;&amp;#x56DE;&amp;#x54EA;&amp;#x4E9B;&amp;#x6570;&amp;#x636E;&amp;#x7C7B;&amp;#x578B;123456789alert(typeof [1, 2]); //&amp;apos;object&amp;apos;alert(typeof &amp;apos;leipeng&amp;apos;); //&amp;apos;string">
<meta property="og:type" content="article">
<meta property="og:title" content="题库-js 篇（上）">
<meta property="og:url" content="https://hongqinma.github.io/2015/07/19/e002-面试题库-js-基础（上）/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="1&amp;#x3001;javascript &amp;#x7684; typeof &amp;#x8FD4;&amp;#x56DE;&amp;#x54EA;&amp;#x4E9B;&amp;#x6570;&amp;#x636E;&amp;#x7C7B;&amp;#x578B;123456789alert(typeof [1, 2]); //&amp;apos;object&amp;apos;alert(typeof &amp;apos;leipeng&amp;apos;); //&amp;apos;string">
<meta property="og:updated_time" content="2016-12-09T02:00:11.492Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="题库-js 篇（上）">
<meta name="twitter:description" content="1&amp;#x3001;javascript &amp;#x7684; typeof &amp;#x8FD4;&amp;#x56DE;&amp;#x54EA;&amp;#x4E9B;&amp;#x6570;&amp;#x636E;&amp;#x7C7B;&amp;#x578B;123456789alert(typeof [1, 2]); //&amp;apos;object&amp;apos;alert(typeof &amp;apos;leipeng&amp;apos;); //&amp;apos;string">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/2015/07/19/e002-面试题库-js-基础（上）/"/>


  <title> 题库-js 篇（上） | HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                题库-js 篇（上）
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2015-07-19T21:36:48+08:00" content="2015-07-19">
              2015-07-19
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/经典题库/" itemprop="url" rel="index">
                    <span itemprop="name">经典题库</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2015/07/19/e002-面试题库-js-基础（上）/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/07/19/e002-面试题库-js-基础（上）/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          

          
            <span id="busuanzi_container_page_pv">  <span id="busuanzi_value_page_pv"></span> Views</span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="1&#x3001;javascript-&#x7684;-typeof-&#x8FD4;&#x56DE;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a href="#1&#x3001;javascript-&#x7684;-typeof-&#x8FD4;&#x56DE;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="headerlink" title="1&#x3001;javascript &#x7684; typeof &#x8FD4;&#x56DE;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x7C7B;&#x578B;"></a>1&#x3001;javascript &#x7684; typeof &#x8FD4;&#x56DE;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">alert(<span class="keyword">typeof</span> [<span class="number">1</span>, <span class="number">2</span>]); <span class="comment">//&apos;object&apos;</span></div><div class="line">alert(<span class="keyword">typeof</span> <span class="string">&apos;leipeng&apos;</span>); <span class="comment">//&apos;string&apos;</span></div><div class="line"><span class="keyword">var</span> i = <span class="literal">true</span>; </div><div class="line">alert(<span class="keyword">typeof</span> i); <span class="comment">//&apos;boolean&apos;</span></div><div class="line">alert(<span class="keyword">typeof</span> <span class="number">1</span>); <span class="comment">//&apos;number&apos;</span></div><div class="line"><span class="keyword">var</span> a; </div><div class="line">alert(<span class="keyword">typeof</span> a); <span class="comment">//&apos;undefined&apos;</span></div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">a</span>(<span class="params"></span>)</span>{;};</div><div class="line">alert(<span class="keyword">typeof</span> a) <span class="comment">//&apos;function&apos;</span></div></pre></td></tr></table></figure>
<h2 id="2&#x3001;3-&#x79CD;&#x5F3A;&#x5236;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x548C;-2-&#x79CD;&#x9690;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;"><a href="#2&#x3001;3-&#x79CD;&#x5F3A;&#x5236;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x548C;-2-&#x79CD;&#x9690;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;" class="headerlink" title="2&#x3001;3 &#x79CD;&#x5F3A;&#x5236;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x548C; 2 &#x79CD;&#x9690;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;"></a>2&#x3001;3 &#x79CD;&#x5F3A;&#x5236;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x548C; 2 &#x79CD;&#x9690;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;</h2><blockquote>
<p>&#x5F3A;&#x5236;&#xFF08;parseInt(),parseFloat(),Number()&#xFF09;<br>&#x9690;&#x5F0F;&#xFF08;== ,!!&#xFF09;</p>
</blockquote>
<h2 id="3&#x3001;split-&#x3001;join-&#x7684;&#x533A;&#x522B;"><a href="#3&#x3001;split-&#x3001;join-&#x7684;&#x533A;&#x522B;" class="headerlink" title="3&#x3001;split() &#x3001;join() &#x7684;&#x533A;&#x522B;"></a>3&#x3001;split() &#x3001;join() &#x7684;&#x533A;&#x522B;</h2><p>&#x524D;&#x8005;&#x662F;&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x5207;&#x5272;&#x6210;&#x6570;&#x7EC4;&#x7684;&#x5F62;&#x5F0F;&#xFF0C;&#x540E;&#x8005;&#x662F;&#x5C06;&#x6570;&#x7EC4;&#x8F6C;&#x6362;&#x6210;&#x5B57;&#x7B26;&#x4E32;</p>
<h2 id="4&#x3001;&#x6570;&#x7EC4;&#x65B9;&#x6CD5;pop-&#x3001;push-&#x3001;unshift-&#x3001;shift"><a href="#4&#x3001;&#x6570;&#x7EC4;&#x65B9;&#x6CD5;pop-&#x3001;push-&#x3001;unshift-&#x3001;shift" class="headerlink" title="4&#x3001;&#x6570;&#x7EC4;&#x65B9;&#x6CD5;pop()&#x3001;push()&#x3001;unshift()&#x3001;shift()"></a>4&#x3001;&#x6570;&#x7EC4;&#x65B9;&#x6CD5;pop()&#x3001;push()&#x3001;unshift()&#x3001;shift()</h2><ul>
<li>Push()&#x5C3E;&#x90E8;&#x6DFB;&#x52A0; pop()&#x5C3E;&#x90E8;&#x5220;&#x9664;</li>
<li>Unshift()&#x5934;&#x90E8;&#x6DFB;&#x52A0; shift()&#x5934;&#x90E8;&#x5220;&#x9664;</li>
</ul>
<h2 id="5&#x3001;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x548C;&#x666E;&#x901A;&#x4E8B;&#x4EF6;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;"><a href="#5&#x3001;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x548C;&#x666E;&#x901A;&#x4E8B;&#x4EF6;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;" class="headerlink" title="5&#x3001;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x548C;&#x666E;&#x901A;&#x4E8B;&#x4EF6;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;"></a>5&#x3001;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x548C;&#x666E;&#x901A;&#x4E8B;&#x4EF6;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;</h2><p>&#x666E;&#x901A;&#x6DFB;&#x52A0;&#x4E8B;&#x4EF6;&#x7684;&#x65B9;&#x6CD5;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> btn = <span class="built_in">document</span>.getElementById(<span class="string">&quot;hello&quot;</span>);</div><div class="line">btn.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line">  alert(<span class="number">1</span>);</div><div class="line">}</div><div class="line">btn.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line">  alert(<span class="number">2</span>);</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x6267;&#x884C;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x53EA;&#x4F1A; alert 2 </p>
<p>&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;&#x4E8B;&#x4EF6;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> btn = <span class="built_in">document</span>.getElementById(<span class="string">&quot;hello&quot;</span>);</div><div class="line">btn.addEventListener(<span class="string">&quot;click&quot;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line">  alert(<span class="number">1</span>);</div><div class="line">},<span class="literal">false</span>);</div><div class="line">btn.addEventListener(<span class="string">&quot;click&quot;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line">  alert(<span class="number">2</span>);</div><div class="line">},<span class="literal">false</span>);</div></pre></td></tr></table></figure>
<p>&#x6267;&#x884C;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x4F1A;&#x5148; alert 1 &#x518D; alert 2</p>
<blockquote>
<p>&#x666E;&#x901A;&#x6DFB;&#x52A0;&#x4E8B;&#x4EF6;&#x7684;&#x65B9;&#x6CD5;&#x4E0D;&#x652F;&#x6301;&#x6DFB;&#x52A0;&#x591A;&#x4E2A;&#x4E8B;&#x4EF6;&#xFF0C;&#x6700;&#x4E0B;&#x9762;&#x7684;&#x4E8B;&#x4EF6;&#x4F1A;&#x8986;&#x76D6;&#x4E0A;&#x9762;&#x7684;&#xFF0C;&#x800C;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#xFF08;addEventListener&#xFF09;&#x65B9;&#x5F0F;&#x6DFB;&#x52A0;&#x4E8B;&#x4EF6;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x591A;&#x4E2A;&#x3002;<br>addEventListener&#x4E0D;&#x517C;&#x5BB9;&#x4F4E;&#x7248;&#x672C;IE&#xFF1B;<br>&#x666E;&#x901A;&#x4E8B;&#x4EF6;&#x65E0;&#x6CD5;&#x53D6;&#x6D88;&#xFF1B;<br>addEventLisntener&#x8FD8;&#x652F;&#x6301;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;+&#x4E8B;&#x4EF6;&#x6355;&#x83B7;</p>
</blockquote>
<h2 id="6&#x3001;IE&#x548C;DOM&#x4E8B;&#x4EF6;&#x6D41;&#x7684;&#x533A;&#x522B;"><a href="#6&#x3001;IE&#x548C;DOM&#x4E8B;&#x4EF6;&#x6D41;&#x7684;&#x533A;&#x522B;" class="headerlink" title="6&#x3001;IE&#x548C;DOM&#x4E8B;&#x4EF6;&#x6D41;&#x7684;&#x533A;&#x522B;"></a>6&#x3001;IE&#x548C;DOM&#x4E8B;&#x4EF6;&#x6D41;&#x7684;&#x533A;&#x522B;</h2><blockquote>
<p>&#x6267;&#x884C;&#x987A;&#x5E8F;&#x4E0D;&#x4E00;&#x6837;<br>&#x53C2;&#x6570;&#x4E0D;&#x4E00;&#x6837;<br>&#x4E8B;&#x4EF6;&#x52A0;&#x4E0D;&#x52A0;on<br>this&#x6307;&#x5411;&#x95EE;&#x9898;</p>
</blockquote>
<h2 id="7&#x3001;IE&#x548C;&#x6807;&#x51C6;&#x4E0B;&#x6709;&#x54EA;&#x4E9B;&#x517C;&#x5BB9;&#x6027;&#x7684;&#x5199;&#x6CD5;"><a href="#7&#x3001;IE&#x548C;&#x6807;&#x51C6;&#x4E0B;&#x6709;&#x54EA;&#x4E9B;&#x517C;&#x5BB9;&#x6027;&#x7684;&#x5199;&#x6CD5;" class="headerlink" title="7&#x3001;IE&#x548C;&#x6807;&#x51C6;&#x4E0B;&#x6709;&#x54EA;&#x4E9B;&#x517C;&#x5BB9;&#x6027;&#x7684;&#x5199;&#x6CD5;"></a>7&#x3001;IE&#x548C;&#x6807;&#x51C6;&#x4E0B;&#x6709;&#x54EA;&#x4E9B;&#x517C;&#x5BB9;&#x6027;&#x7684;&#x5199;&#x6CD5;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> ev = ev || <span class="built_in">window</span>.event;</div><div class="line"><span class="built_in">document</span>.documentElement.clientWidth || <span class="built_in">document</span>.body.clientWidth;</div><div class="line"><span class="keyword">var</span> target = ev.srcElement||ev.target;</div></pre></td></tr></table></figure>
<h2 id="8&#x3001;call&#x3001;apply&#x548C;bind&#x7684;&#x533A;&#x522B;"><a href="#8&#x3001;call&#x3001;apply&#x548C;bind&#x7684;&#x533A;&#x522B;" class="headerlink" title="8&#x3001;call&#x3001;apply&#x548C;bind&#x7684;&#x533A;&#x522B;"></a>8&#x3001;call&#x3001;apply&#x548C;bind&#x7684;&#x533A;&#x522B;</h2><p>call&#x65B9;&#x6CD5;: </p>
<p>&#x8BED;&#x6CD5;&#xFF1A;call(thisObj&#xFF0C;Object1,Object2&#x2026;)</p>
<p>&#x5B9A;&#x4E49;&#xFF1A;&#x8C03;&#x7528;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x4EE5;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x66FF;&#x6362;&#x5F53;&#x524D;&#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x8BF4;&#x660E;&#xFF1A;</p>
<blockquote>
<p>call &#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x4EE3;&#x66FF;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x8C03;&#x7528;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x3002;<br>call &#x65B9;&#x6CD5;&#x53EF;&#x5C06;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x5BF9;&#x8C61;&#x4E0A;&#x4E0B;&#x6587;&#x4ECE;&#x521D;&#x59CB;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x6539;&#x53D8;&#x4E3A;&#x7531; thisObj &#x6307;&#x5B9A;&#x7684;&#x65B0;&#x5BF9;&#x8C61;&#x3002;<br>&#x5982;&#x679C;&#x6CA1;&#x6709;&#x63D0;&#x4F9B; thisObj &#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48; Global &#x5BF9;&#x8C61;&#x88AB;&#x7528;&#x4F5C; thisObj&#x3002; </p>
</blockquote>
<p>apply&#x65B9;&#x6CD5;&#xFF1A;</p>
<p>&#x8BED;&#x6CD5;&#xFF1A;apply(thisObj&#xFF0C;[argArray])</p>
<p>&#x5B9A;&#x4E49;&#xFF1A;&#x5E94;&#x7528;&#x67D0;&#x4E00;&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x66FF;&#x6362;&#x5F53;&#x524D;&#x5BF9;&#x8C61;&#x3002; </p>
<p>&#x8BF4;&#x660E;&#xFF1A; </p>
<blockquote>
<p>&#x5982;&#x679C; argArray &#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x6709;&#x6548;&#x7684;&#x6570;&#x7EC4;&#x6216;&#x8005;&#x4E0D;&#x662F; arguments &#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48;&#x5C06;&#x5BFC;&#x81F4;&#x4E00;&#x4E2A; TypeError&#x3002;<br>&#x5982;&#x679C;&#x6CA1;&#x6709;&#x63D0;&#x4F9B; argArray &#x548C; thisObj &#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48; Global &#x5BF9;&#x8C61;&#x5C06;&#x88AB;&#x7528;&#x4F5C; thisObj&#xFF0C;&#x5E76;&#x4E14;&#x65E0;&#x6CD5;&#x88AB;&#x4F20;&#x9012;&#x4EFB;&#x4F55;&#x53C2;&#x6570;&#x3002;</p>
</blockquote>
<p>bind &#x65B9;&#x6CD5;&#xFF1A;</p>
<blockquote>
<p>bind&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x7ED9;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x9010;&#x4E2A;&#x5217;&#x51FA;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5199;&#x5728;&#x6570;&#x7EC4;&#x4E2D;&#x3002;<br>bind&#x65B9;&#x6CD5;&#x4E0E;call&#x3001;apply&#x6700;&#x5927;&#x7684;&#x4E0D;&#x540C;&#x5C31;&#x662F;&#x524D;&#x8005;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED1;&#x5B9A;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x800C;&#x540E;&#x4E24;&#x8005;&#x662F;&#x76F4;&#x63A5;&#x6267;&#x884C;&#x4E86;&#x51FD;&#x6570;<br>&#x8BE5;&#x65B9;&#x6CD5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x51FD;&#x6570;&#xFF0C;&#x79F0;&#x4E3A;&#x7ED1;&#x5B9A;&#x51FD;&#x6570;&#xFF0C;&#x7ED1;&#x5B9A;&#x51FD;&#x6570;&#x4F1A;&#x4EE5;&#x521B;&#x5EFA;&#x5B83;&#x65F6;&#x4F20;&#x5165;bind&#x65B9;&#x6CD5;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F5C;&#x4E3A;this;<br>&#x4F20;&#x5165;bind&#x65B9;&#x6CD5;&#x7684;&#x7B2C;&#x4E8C;&#x4E2A;&#x4EE5;&#x53CA;&#x4EE5;&#x540E;&#x7684;&#x53C2;&#x6570;&#x52A0;&#x4E0A;&#x7ED1;&#x5B9A;&#x51FD;&#x6570;&#x8FD0;&#x884C;&#x65F6;&#x672C;&#x8EAB;&#x7684;&#x53C2;&#x6570;&#x6309;&#x7167;&#x987A;&#x5E8F;&#x4F5C;&#x4E3A;&#x539F;&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x6765;&#x8C03;&#x7528;&#x539F;&#x51FD;&#x6570;&#x3002;</p>
</blockquote>
<p><a href="http://www.cnblogs.com/xljzlw/p/3775162.html" target="_blank" rel="external">js&#x4E2D;call&#x3001;apply&#x3001;bind&#x7684;&#x7528;&#x6CD5;</a></p>
<h2 id="&#x51FD;&#x6570;&#x8C03;&#x7528;&#x3001;this&#x6307;&#x5411;&#x3001;&#x8FD4;&#x56DE;&#x503C;"><a href="#&#x51FD;&#x6570;&#x8C03;&#x7528;&#x3001;this&#x6307;&#x5411;&#x3001;&#x8FD4;&#x56DE;&#x503C;" class="headerlink" title="&#x51FD;&#x6570;&#x8C03;&#x7528;&#x3001;this&#x6307;&#x5411;&#x3001;&#x8FD4;&#x56DE;&#x503C;"></a>&#x51FD;&#x6570;&#x8C03;&#x7528;&#x3001;this&#x6307;&#x5411;&#x3001;&#x8FD4;&#x56DE;&#x503C;</h2><p><strong>&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x6700;&#x7EC8;&#x4EA7;&#x751F;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x7ED3;&#x6784;&#xFF0C;&#x8DDF;&#x5982;&#x4F55;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x606F;&#x606F;&#x76F8;&#x5173;&#xFF1A;&#x51FD;&#x6570;&#x7684;&#x56DB;&#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;</strong></p>
<h3 id="&#x51FD;&#x6570;&#x7684;-4-&#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;"><a href="#&#x51FD;&#x6570;&#x7684;-4-&#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;" class="headerlink" title="&#x51FD;&#x6570;&#x7684; 4 &#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;"></a>&#x51FD;&#x6570;&#x7684; 4 &#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;</h3><ol>
<li>&#x7B2C;&#x4E00;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5199;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528;&#x4E00;&#x4E0B;</li>
<li>&#x7B2C;&#x4E8C;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5C06;&#x51FD;&#x6570;&#x6210;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x6765;&#x8C03;&#x7528;</li>
<li>&#x7B2C;&#x4E09;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5C06;&#x51FD;&#x6570;&#x5F53;&#x6210;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6765;&#x8C03;&#x7528;</li>
<li>&#x7B2C;&#x56DB;&#x79CD;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#xFF1A;&#x4E0A;&#x4E0B;&#x6587;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#xFF0C;&#x6839;&#x636E;&#x8C03;&#x7528;&#x65B9;&#x5F0F;&#x7684;&#x4E0D;&#x540C;&#x53EF;&#x4EE5;&#x4EA7;&#x751F;&#x4E0D;&#x540C;&#x7684;&#x7ED3;&#x679C;</li>
</ol>
<p>&#x7B2C;&#x56DB;&#x79CD;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x7684;&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;</p>
<ul>
<li>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;&#xFF1A;call/apply (apply &#x548C; call &#x7684;&#x552F;&#x4E00;&#x533A;&#x522B;&#x662F;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x6570;&#x7EC4;&#xFF0C;&#x5C06;&#x5B9E;&#x53C2;&#x503C;&#x4E00;&#x4E00;&#x4F20;&#x5230;&#x6570;&#x7EC4;&#x4E2D;&#x3002;fn.call (&#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684; this &#x7684;&#x503C;,&#x5B9E;&#x53C2;1&#xFF0C;&#x5B9E;&#x53C2;2&#x2026;))</li>
</ul>
<h3 id="&#x4E0D;&#x540C;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;this&#x7684;&#x503C;"><a href="#&#x4E0D;&#x540C;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;this&#x7684;&#x503C;" class="headerlink" title="&#x4E0D;&#x540C;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;this&#x7684;&#x503C;"></a>&#x4E0D;&#x540C;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;this&#x7684;&#x503C;</h3><ol>
<li>&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D; this &#x6307;&#x5411;&#xFF1A;window</li>
<li>&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D; this &#x6307;&#x5411;&#xFF1A;&#x8C03;&#x7528;&#x7684;&#x5BF9;&#x8C61;</li>
<li>&#x6784;&#x9020;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D; this &#x6307;&#x5411;&#xFF1A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x4F8B;</li>
<li>&#x4E0A;&#x4E0B;&#x6587;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D; this &#x6307;&#x5411;&#xFF1A;</li>
</ol>
<ul>
<li>(1) &#x5982;&#x679C; call &#x65B9;&#x6CD5;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5219; fn &#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684; this &#x7684;&#x503C;&#x6307;&#x5411;&#x8BE5;&#x5BF9;&#x8C61;</li>
<li>(2) &#x5982;&#x679C; call &#x65B9;&#x6CD5;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x3001;&#x6570;&#x5B57;&#x3001;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x5219; fn &#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684; this &#x7684;&#x503C;&#x4F1A;&#x8F6C;&#x6362;&#x4E3A;&#x8BE5;&#x7C7B;&#x578B;&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x57FA;&#x672C;&#x5305;&#x88C5;&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;</li>
<li>(3) &#x5982;&#x679C; call &#x65B9;&#x6CD5;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F; null &#xFF0C;&#x5219; fn &#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684; this &#x7684;&#x503C;&#x662F; window &#x2014;&#x2014;&gt; &#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x662F;&#x4E00;&#x6B21;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;</li>
</ul>
<h3 id="&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;"><a href="#&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;" class="headerlink" title="&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;"></a>&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;</h3><ol>
<li>&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x7531; return &#x8BED;&#x53E5;&#x51B3;&#x5B9A;</li>
<li>&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x7531; return &#x8BED;&#x53E5;&#x51B3;&#x5B9A;</li>
<li>&#x6784;&#x9020;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#xFF1A;</li>
</ol>
<ul>
<li>(1). &#x5982;&#x679C;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x624B;&#x52A8;&#x8BBE;&#x7F6E;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x90A3;&#x4E48;&#x4F1A;&#x8FD4;&#x56DE;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x4F8B;</li>
<li>(2). &#x5982;&#x679C;&#x624B;&#x52A8;&#x7ED9;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6DFB;&#x52A0;&#x4E86;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x6709;&#x4EE5;&#x4E0B;2&#x79CD;&#x60C5;&#x51B5;&#xFF1A;<ul>
<li>(a). &#x8FD4;&#x56DE;&#x503C;&#x662F;&#x503C;&#x7C7B;&#x578B;&#xFF1A;&#x6700;&#x7EC8;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x8FD8;&#x662F;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x4F8B;</li>
<li>(b). &#x8FD4;&#x56DE;&#x503C;&#x662F;&#x5F15;&#x7528;&#x7C7B;&#x578B;(&#x5BF9;&#x8C61;)&#xFF1A;&#x6700;&#x7EC8;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x5C31;&#x662F;&#x8BE5;&#x5BF9;&#x8C61;</li>
</ul>
</li>
</ul>
<ol>
<li>&#x4E0A;&#x4E0B;&#x6587;&#x8C03;&#x7528;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x7531; return &#x8BED;&#x53E5;&#x51B3;&#x5B9A;</li>
</ol>
<h2 id="9&#x3001;b-&#x7EE7;&#x627F;-a-&#x7684;&#x65B9;&#x6CD5;"><a href="#9&#x3001;b-&#x7EE7;&#x627F;-a-&#x7684;&#x65B9;&#x6CD5;" class="headerlink" title="9&#x3001;b &#x7EE7;&#x627F; a &#x7684;&#x65B9;&#x6CD5;"></a>9&#x3001;b &#x7EE7;&#x627F; a &#x7684;&#x65B9;&#x6CD5;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">A</span>(<span class="params"> age, name </span>)</span>{ </div><div class="line">  <span class="keyword">this</span>.age = age; </div><div class="line">  <span class="keyword">this</span>.name = name; </div><div class="line">}</div><div class="line">A.prototype.show = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{ </div><div class="line">  alert(<span class="string">&apos;&#x7236;&#x7EA7;&#x65B9;&#x6CD5;&apos;</span>); </div><div class="line">}</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">B</span>(<span class="params">age,name,job</span>)</span>{ </div><div class="line">  A.apply( <span class="keyword">this</span>, <span class="built_in">arguments</span> ); </div><div class="line">  <span class="keyword">this</span>.job = job; </div><div class="line">} </div><div class="line">B.prototype = <span class="keyword">new</span> A();</div><div class="line"><span class="keyword">var</span> b = <span class="keyword">new</span> A(<span class="number">14</span>,<span class="string">&apos;&#x4FA0;&#x5BA2;&#x884C;&apos;</span>); </div><div class="line"><span class="keyword">var</span> a = <span class="keyword">new</span> B(<span class="number">15</span>,<span class="string">&apos;&#x72FC;&#x4FA0;&apos;</span>,<span class="string">&apos;&#x4FA0;&#x5BA2;&apos;</span>);</div></pre></td></tr></table></figure>
<h2 id="10&#x3001;&#x5982;&#x4F55;&#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x548C;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;"><a href="#10&#x3001;&#x5982;&#x4F55;&#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x548C;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;" class="headerlink" title="10&#x3001;&#x5982;&#x4F55;&#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x548C;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;"></a>10&#x3001;&#x5982;&#x4F55;&#x963B;&#x6B62;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x548C;&#x9ED8;&#x8BA4;&#x4E8B;&#x4EF6;</h2><blockquote>
<p>canceBubble() &#x53EA;&#x652F;&#x6301; IE,return false,stopPropagation()</p>
</blockquote>
<h2 id="11&#x3001;&#x6DFB;&#x52A0;&#x3001;&#x5220;&#x9664;&#x3001;&#x66FF;&#x6362;&#x3001;&#x63D2;&#x5165;&#x5230;&#x67D0;&#x4E2A;&#x63A5;&#x70B9;&#x7684;&#x65B9;&#x6CD5;"><a href="#11&#x3001;&#x6DFB;&#x52A0;&#x3001;&#x5220;&#x9664;&#x3001;&#x66FF;&#x6362;&#x3001;&#x63D2;&#x5165;&#x5230;&#x67D0;&#x4E2A;&#x63A5;&#x70B9;&#x7684;&#x65B9;&#x6CD5;" class="headerlink" title="11&#x3001;&#x6DFB;&#x52A0;&#x3001;&#x5220;&#x9664;&#x3001;&#x66FF;&#x6362;&#x3001;&#x63D2;&#x5165;&#x5230;&#x67D0;&#x4E2A;&#x63A5;&#x70B9;&#x7684;&#x65B9;&#x6CD5;"></a>11&#x3001;&#x6DFB;&#x52A0;&#x3001;&#x5220;&#x9664;&#x3001;&#x66FF;&#x6362;&#x3001;&#x63D2;&#x5165;&#x5230;&#x67D0;&#x4E2A;&#x63A5;&#x70B9;&#x7684;&#x65B9;&#x6CD5;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">domObj.appendChild();</div><div class="line">domObj.insertBefore();</div><div class="line">domObj.replaceChild();</div><div class="line">domObj.removeChild();</div></pre></td></tr></table></figure>
<h2 id="12&#x3001;javascript&#x7684;&#x672C;&#x5730;&#x5BF9;&#x8C61;&#xFF0C;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x548C;&#x5BBF;&#x4E3B;&#x5BF9;&#x8C61;"><a href="#12&#x3001;javascript&#x7684;&#x672C;&#x5730;&#x5BF9;&#x8C61;&#xFF0C;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x548C;&#x5BBF;&#x4E3B;&#x5BF9;&#x8C61;" class="headerlink" title="12&#x3001;javascript&#x7684;&#x672C;&#x5730;&#x5BF9;&#x8C61;&#xFF0C;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x548C;&#x5BBF;&#x4E3B;&#x5BF9;&#x8C61;"></a>12&#x3001;javascript&#x7684;&#x672C;&#x5730;&#x5BF9;&#x8C61;&#xFF0C;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x548C;&#x5BBF;&#x4E3B;&#x5BF9;&#x8C61;</h2><blockquote>
<p>&#x672C;&#x5730;&#x5BF9;&#x8C61;&#x4E3A; Array Object Regexp &#x7B49;&#x53EF;&#x4EE5; new &#x5B9E;&#x4F8B;&#x5316;<br>&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x4E3A; Global Math &#x7B49;&#x4E0D;&#x53EF;&#x4EE5;&#x5B9E;&#x4F8B;&#x5316;&#x7684;<br>&#x5BBF;&#x4E3B;&#x4E3A;&#x6D4F;&#x89C8;&#x5668;&#x81EA;&#x5E26;&#x7684; document, window &#x7B49;</p>
</blockquote>
<h2 id="13-window-onload-&#x548C;-document-ready-&#x7684;&#x533A;&#x522B;"><a href="#13-window-onload-&#x548C;-document-ready-&#x7684;&#x533A;&#x522B;" class="headerlink" title="13. window.onload &#x548C; document ready &#x7684;&#x533A;&#x522B;"></a>13. window.onload &#x548C; document ready &#x7684;&#x533A;&#x522B;</h2><blockquote>
<p>window.onload &#x662F;&#x5728;dom&#x6587;&#x6863;&#x6811;&#x52A0;&#x8F7D;&#x5B8C;&#x548C;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x52A0;&#x8F7D;&#x5B8C;&#x4E4B;&#x540E;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;;<br>Document.ready &#x539F;&#x751F;&#x79CD;&#x6CA1;&#x6709;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;<br>jquery&#x4E2D;&#x6709; $().ready(function),&#x5728;dom&#x6587;&#x6863;&#x6811;&#x52A0;&#x8F7D;&#x5B8C;&#x4E4B;&#x540E;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;<br>&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x91CC;&#x9762;&#x7684;&#x6587;&#x6863;&#x6811;&#x52A0;&#x8F7D;&#x5B8C;&#x4E0D;&#x4EE3;&#x8868;&#x5168;&#x90E8;&#x6587;&#x4EF6;&#x52A0;&#x8F7D;&#x5B8C;&#x3002;<br>$(document).ready &#x8981;&#x6BD4; window.onload &#x5148;&#x6267;&#x884C;<br>window.onload&#x53EA;&#x80FD;&#x51FA;&#x6765;&#x4E00;&#x6B21;&#xFF0C;$(document).ready &#x53EF;&#x4EE5;&#x51FA;&#x73B0;&#x591A;&#x6B21;</p>
</blockquote>
<h2 id="14&#x3001;&#x201D;-&#x201D;-&#x548C;-&#x201C;-&#x201D;-&#x7684;&#x4E0D;&#x540C;"><a href="#14&#x3001;&#x201D;-&#x201D;-&#x548C;-&#x201C;-&#x201D;-&#x7684;&#x4E0D;&#x540C;" class="headerlink" title="14&#x3001;&#x201D;==&#x201D; &#x548C; &#x201C;===&#x201D; &#x7684;&#x4E0D;&#x540C;"></a>14&#x3001;&#x201D;==&#x201D; &#x548C; &#x201C;===&#x201D; &#x7684;&#x4E0D;&#x540C;</h2><p>&#x524D;&#x8005;&#x4F1A;&#x81EA;&#x52A8;&#x8F6C;&#x6362;&#x7C7B;&#x578B;&#xFF0C;&#x540E;&#x8005;&#x4E0D;&#x4F1A;</p>
<h2 id="15&#x3001;javascript&#x7684;&#x540C;&#x6E90;&#x7B56;&#x7565;"><a href="#15&#x3001;javascript&#x7684;&#x540C;&#x6E90;&#x7B56;&#x7565;" class="headerlink" title="15&#x3001;javascript&#x7684;&#x540C;&#x6E90;&#x7B56;&#x7565;"></a>15&#x3001;javascript&#x7684;&#x540C;&#x6E90;&#x7B56;&#x7565;</h2><blockquote>
<p>&#x4E00;&#x6BB5;&#x811A;&#x672C;&#x53EA;&#x80FD;&#x8BFB;&#x53D6;&#x6765;&#x81EA;&#x4E8E;&#x540C;&#x4E00;&#x6765;&#x6E90;&#x7684;&#x7A97;&#x53E3;&#x548C;&#x6587;&#x6863;&#x7684;&#x5C5E;<br>&#x8FD9;&#x91CC;&#x7684;&#x540C;&#x4E00;&#x6765;&#x6E90;&#x6307;&#x7684;&#x662F;&#x4E3B;&#x673A;&#x540D;&#x3001;&#x8BAE;&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#x7684;&#x7EC4;&#x5408;</p>
</blockquote>
<h2 id="16&#x3001;JavaScript-&#x662F;&#x4E00;&#x95E8;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x8BED;&#x8A00;&#xFF0C;&#x5B83;&#x7684;&#x7279;&#x70B9;"><a href="#16&#x3001;JavaScript-&#x662F;&#x4E00;&#x95E8;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x8BED;&#x8A00;&#xFF0C;&#x5B83;&#x7684;&#x7279;&#x70B9;" class="headerlink" title="16&#x3001;JavaScript &#x662F;&#x4E00;&#x95E8;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x8BED;&#x8A00;&#xFF0C;&#x5B83;&#x7684;&#x7279;&#x70B9;"></a>16&#x3001;JavaScript &#x662F;&#x4E00;&#x95E8;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x8BED;&#x8A00;&#xFF0C;&#x5B83;&#x7684;&#x7279;&#x70B9;</h2><p>javaScript &#x4E00;&#x79CD;&#x76F4;&#x8BD1;&#x5F0F;&#x811A;&#x672C;&#x8BED;&#x8A00;&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x52A8;&#x6001;&#x7C7B;&#x578B;&#x3001;&#x5F31;&#x7C7B;&#x578B;&#x3001;&#x57FA;&#x4E8E;&#x539F;&#x578B;&#x7684;&#x8BED;&#x8A00;&#xFF0C;&#x5185;&#x7F6E;&#x652F;&#x6301;&#x7C7B;&#x578B;&#x3002;<br>&#x5B83;&#x7684;&#x89E3;&#x91CA;&#x5668;&#x88AB;&#x79F0;&#x4E3A; JavaScript &#x5F15;&#x64CE;&#xFF0C;&#x4E3A;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x5E7F;&#x6CDB;&#x7528;&#x4E8E;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x811A;&#x672C;&#x8BED;&#x8A00;&#xFF0C;&#x6700;&#x65E9;&#x662F;&#x5728; HTML &#x7F51;&#x9875;&#x4E0A;&#x4F7F;&#x7528;&#xFF0C;&#x7528;&#x6765;&#x7ED9; HTML &#x7F51;&#x9875;&#x589E;&#x52A0;&#x52A8;&#x6001;&#x529F;&#x80FD;&#x3002;<br>JavaScript &#x517C;&#x5BB9;&#x4E8E; ECMA &#x6807;&#x51C6;&#xFF0C;&#x56E0;&#x6B64;&#x4E5F;&#x79F0;&#x4E3A; ECMAScript&#x3002;</p>
<p>&#x57FA;&#x672C;&#x7279;&#x70B9;&#xFF1A;</p>
<blockquote>
<p>&#x662F;&#x4E00;&#x79CD;&#x89E3;&#x91CA;&#x6027;&#x811A;&#x672C;&#x8BED;&#x8A00;&#xFF08;&#x4EE3;&#x7801;&#x4E0D;&#x8FDB;&#x884C;&#x9884;&#x7F16;&#x8BD1;&#xFF09;&#x3002;<br>&#x4E3B;&#x8981;&#x7528;&#x6765;&#x5411;HTML&#xFF08;&#x6807;&#x51C6;&#x901A;&#x7528;&#x6807;&#x8BB0;&#x8BED;&#x8A00;&#x4E0B;&#x7684;&#x4E00;&#x4E2A;&#x5E94;&#x7528;&#xFF09;&#x9875;&#x9762;&#x6DFB;&#x52A0;&#x4EA4;&#x4E92;&#x884C;&#x4E3A;&#x3002;<br>&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5D4C;&#x5165;HTML&#x9875;&#x9762;&#xFF0C;&#x4F46;&#x5199;&#x6210;&#x5355;&#x72EC;&#x7684;js&#x6587;&#x4EF6;&#x6709;&#x5229;&#x4E8E;&#x7ED3;&#x6784;&#x548C;&#x884C;&#x4E3A;&#x7684;&#x5206;&#x79BB;&#x3002;<br>&#x8DE8;&#x5E73;&#x53F0;&#x7279;&#x6027;&#xFF0C;&#x5728;&#x7EDD;&#x5927;&#x591A;&#x6570;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x652F;&#x6301;&#x4E0B;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x591A;&#x79CD;&#x5E73;&#x53F0;&#x4E0B;&#x8FD0;&#x884C;&#xFF08;&#x5982;Windows&#x3001;Linux&#x3001;Mac&#x3001;Android&#x3001;iOS&#x7B49;&#xFF09;&#x3002;</p>
</blockquote>
<h2 id="17&#x3001;JavaScript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a href="#17&#x3001;JavaScript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="headerlink" title="17&#x3001;JavaScript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;"></a>17&#x3001;JavaScript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2><blockquote>
<p>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF1A;String, boolean, Number, Undefined, Null<br>&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF1A;Object(Array, Date, RegExp, Function)</p>
</blockquote>
<p>&#x5982;&#x4F55;&#x5224;&#x65AD;&#x67D0;&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x6570;&#x7EC4;&#x6570;&#x636E;&#x7C7B;&#x578B;?</p>
<blockquote>
<p>&#x65B9;&#x6CD5;&#x4E00;.&#x5224;&#x65AD;&#x5176;&#x662F;&#x5426;&#x5177;&#x6709;&#x201C;&#x6570;&#x7EC4;&#x6027;&#x8D28;&#x201D;&#xFF0C;&#x5982;slice()&#x65B9;&#x6CD5;&#x3002;&#x53EF;&#x81EA;&#x5DF1;&#x7ED9;&#x8BE5;&#x53D8;&#x91CF;&#x5B9A;&#x4E49; slice &#x65B9;&#x6CD5;&#xFF0C;&#x6545;&#x6709;&#x65F6;&#x4F1A;&#x5931;&#x6548;<br>&#x65B9;&#x6CD5;&#x4E8C;.obj instanceof Array &#x5728;&#x67D0;&#x4E9B; IE &#x7248;&#x672C;&#x4E2D;&#x4E0D;&#x6B63;&#x786E;<br>&#x65B9;&#x6CD5;&#x4E09;.&#x65B9;&#x6CD5;&#x4E00;&#x4E8C;&#x7686;&#x6709;&#x6F0F;&#x6D1E;&#xFF0C;&#x5728; ECMAScript5 &#x4E2D;&#x5B9A;&#x4E49;&#x4E86;&#x65B0;&#x65B9;&#x6CD5; Array.isArray(), &#x4FDD;&#x8BC1;&#x5176;&#x517C;&#x5BB9;&#x6027;&#xFF0C;&#x6700;&#x597D;&#x7684;&#x65B9;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">if</span>(<span class="keyword">typeof</span> <span class="built_in">Array</span>.isArray===<span class="string">&quot;undefined&quot;</span>) {</div><div class="line">  <span class="built_in">Array</span>.isArray = <span class="function"><span class="keyword">function</span>(<span class="params">arg</span>)</span>{</div><div class="line">    <span class="keyword">return</span> <span class="built_in">Object</span>.prototype.toString.call(arg)===<span class="string">&quot;[object Array]&quot;</span>;</div><div class="line">  };</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="18-&#x5DF2;&#x77E5;-ID-&#x7684;-Input-&#x8F93;&#x5165;&#x6846;&#xFF0C;&#x83B7;&#x53D6;&#x8FD9;&#x4E2A;&#x8F93;&#x5165;&#x6846;&#x7684;&#x8F93;&#x5165;&#x503C;&#xFF0C;&#x600E;&#x4E48;&#x505A;&#xFF1F;"><a href="#18-&#x5DF2;&#x77E5;-ID-&#x7684;-Input-&#x8F93;&#x5165;&#x6846;&#xFF0C;&#x83B7;&#x53D6;&#x8FD9;&#x4E2A;&#x8F93;&#x5165;&#x6846;&#x7684;&#x8F93;&#x5165;&#x503C;&#xFF0C;&#x600E;&#x4E48;&#x505A;&#xFF1F;" class="headerlink" title="18. &#x5DF2;&#x77E5; ID &#x7684; Input &#x8F93;&#x5165;&#x6846;&#xFF0C;&#x83B7;&#x53D6;&#x8FD9;&#x4E2A;&#x8F93;&#x5165;&#x6846;&#x7684;&#x8F93;&#x5165;&#x503C;&#xFF0C;&#x600E;&#x4E48;&#x505A;&#xFF1F;"></a>18. &#x5DF2;&#x77E5; ID &#x7684; Input &#x8F93;&#x5165;&#x6846;&#xFF0C;&#x83B7;&#x53D6;&#x8FD9;&#x4E2A;&#x8F93;&#x5165;&#x6846;&#x7684;&#x8F93;&#x5165;&#x503C;&#xFF0C;&#x600E;&#x4E48;&#x505A;&#xFF1F;</h2><blockquote>
<p>document.getElementById(&#x201C;ID&#x201D;).value;</p>
</blockquote>
<h2 id="19&#x3001;&#x83B7;&#x53D6;&#x5230;&#x9875;&#x9762;&#x4E2D;&#x6240;&#x6709;-checkbox"><a href="#19&#x3001;&#x83B7;&#x53D6;&#x5230;&#x9875;&#x9762;&#x4E2D;&#x6240;&#x6709;-checkbox" class="headerlink" title="19&#x3001;&#x83B7;&#x53D6;&#x5230;&#x9875;&#x9762;&#x4E2D;&#x6240;&#x6709; checkbox"></a>19&#x3001;&#x83B7;&#x53D6;&#x5230;&#x9875;&#x9762;&#x4E2D;&#x6240;&#x6709; checkbox</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> domList = <span class="built_in">document</span>.getElementsByTagName(<span class="string">&apos;input&apos;</span>);</div><div class="line"><span class="keyword">var</span> checkBoxList = [];</div><div class="line"><span class="keyword">var</span> len = domList.length;&#x3000;&#x3000;<span class="comment">//&#x7F13;&#x5B58;&#x5230;&#x5C40;&#x90E8;&#x53D8;&#x91CF;</span></div><div class="line"><span class="keyword">while</span> (len--) {&#x3000;&#x3000;<span class="comment">//&#x4F7F;&#x7528;while&#x7684;&#x6548;&#x7387;&#x4F1A;&#x6BD4;for&#x5FAA;&#x73AF;&#x66F4;&#x9AD8;</span></div><div class="line">&#x3000;&#x3000;<span class="keyword">if</span> (domList[len].type == <span class="string">&apos;checkbox&apos;</span>) {</div><div class="line">    &#x3000;&#x3000;checkBoxList.push(domList[len]);</div><div class="line">&#x3000;&#x3000;}</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="20-&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5DF2;&#x77E5;-ID-&#x7684;-DIV-&#x7684;-html-&#x5185;&#x5BB9;&#x4E3A;-xxxx-&#xFF0C;&#x5B57;&#x4F53;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x4E3A;&#x9ED1;&#x8272;"><a href="#20-&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5DF2;&#x77E5;-ID-&#x7684;-DIV-&#x7684;-html-&#x5185;&#x5BB9;&#x4E3A;-xxxx-&#xFF0C;&#x5B57;&#x4F53;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x4E3A;&#x9ED1;&#x8272;" class="headerlink" title="20. &#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5DF2;&#x77E5; ID &#x7684; DIV &#x7684; html &#x5185;&#x5BB9;&#x4E3A; xxxx &#xFF0C;&#x5B57;&#x4F53;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x4E3A;&#x9ED1;&#x8272;"></a>20. &#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5DF2;&#x77E5; ID &#x7684; DIV &#x7684; html &#x5185;&#x5BB9;&#x4E3A; xxxx &#xFF0C;&#x5B57;&#x4F53;&#x989C;&#x8272;&#x8BBE;&#x7F6E;&#x4E3A;&#x9ED1;&#x8272;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> dom = <span class="built_in">document</span>.getElementById(<span class="string">&quot;ID&quot;</span>);</div><div class="line">dom.innerHTML = <span class="string">&quot;xxxx&quot;</span></div><div class="line">dom.style.color = <span class="string">&quot;#000&quot;</span></div></pre></td></tr></table></figure>
<h2 id="21-&#x5F53;&#x4E00;&#x4E2A;-DOM-&#x8282;&#x70B9;&#x88AB;&#x70B9;&#x51FB;&#x65F6;&#x5019;&#x80FD;&#x591F;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;"><a href="#21-&#x5F53;&#x4E00;&#x4E2A;-DOM-&#x8282;&#x70B9;&#x88AB;&#x70B9;&#x51FB;&#x65F6;&#x5019;&#x80FD;&#x591F;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;" class="headerlink" title="21. &#x5F53;&#x4E00;&#x4E2A; DOM &#x8282;&#x70B9;&#x88AB;&#x70B9;&#x51FB;&#x65F6;&#x5019;&#x80FD;&#x591F;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;"></a>21. &#x5F53;&#x4E00;&#x4E2A; DOM &#x8282;&#x70B9;&#x88AB;&#x70B9;&#x51FB;&#x65F6;&#x5019;&#x80FD;&#x591F;&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;</h2><blockquote>
<p>&#x76F4;&#x63A5;&#x5728;DOM&#x91CC;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#xFF1A;<code>&lt;div onclick=&quot;test()&quot;&gt;&lt;/div&gt;</code><br>&#x5728; JS &#x91CC;&#x901A;&#x8FC7; onclick &#x7ED1;&#x5B9A;&#xFF1A;xxx.onclick = test;<br>&#x901A;&#x8FC7;&#x4E8B;&#x4EF6;&#x6DFB;&#x52A0;&#x8FDB;&#x884C;&#x7ED1;&#x5B9A;&#xFF1A;addEventListener(xxx, &#x2018;click&#x2019;, test);</p>
</blockquote>
<p>Javascript&#x7684;&#x4E8B;&#x4EF6;&#x6D41;&#x6A21;&#x578B;&#x90FD;&#x6709;&#x4EC0;&#x4E48;&#xFF1F;</p>
<blockquote>
<p>&#x201C;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x201D;&#xFF1A;&#x4E8B;&#x4EF6;&#x5F00;&#x59CB;&#x7531;&#x6700;&#x5177;&#x4F53;&#x7684;&#x5143;&#x7D20;&#x63A5;&#x53D7;&#xFF0C;&#x7136;&#x540E;&#x9010;&#x7EA7;&#x5411;&#x4E0A;&#x4F20;&#x64AD;<br>&#x201C;&#x4E8B;&#x4EF6;&#x6355;&#x6349;&#x201D;&#xFF1A;&#x4E8B;&#x4EF6;&#x7531;&#x6700;&#x4E0D;&#x5177;&#x4F53;&#x7684;&#x8282;&#x70B9;&#x5148;&#x63A5;&#x6536;&#xFF0C;&#x7136;&#x540E;&#x9010;&#x7EA7;&#x5411;&#x4E0B;&#xFF0C;&#x4E00;&#x76F4;&#x5230;&#x6700;&#x5177;&#x4F53;&#x7684;<br>&#x201C;DOM&#x4E8B;&#x4EF6;&#x6D41;&#x201D;&#xFF1A;&#x4E09;&#x4E2A;&#x9636;&#x6BB5;&#xFF1A;&#x4E8B;&#x4EF6;&#x6355;&#x6349;&#xFF0C;&#x76EE;&#x6807;&#x9636;&#x6BB5;&#xFF0C;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;</p>
</blockquote>
<h2 id="22-&#x4EE3;&#x7801;&#x9898;"><a href="#22-&#x4EE3;&#x7801;&#x9898;" class="headerlink" title="22. &#x4EE3;&#x7801;&#x9898;"></a>22. &#x4EE3;&#x7801;&#x9898;</h2><h3 id="undefined&#x3001;-&#x62A5;&#x9519;"><a href="#undefined&#x3001;-&#x62A5;&#x9519;" class="headerlink" title="undefined&#x3001; &#x62A5;&#x9519;"></a>undefined&#x3001; &#x62A5;&#x9519;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a;</div><div class="line">alert(<span class="keyword">typeof</span> a); <span class="comment">// &quot;undefined&quot;</span></div><div class="line">alert(b); <span class="comment">// &#x62A5;&#x9519;</span></div></pre></td></tr></table></figure>
<blockquote>
<p>&#x89E3;&#x91CA;&#xFF1A;undefined &#x662F;&#x4E00;&#x4E2A;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x503C;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x4E2A;&#x503C;&#x5C31;&#x662F; &#x201C;undefined&#x201D;&#xFF0C;<br>&#x5728;&#x4F7F;&#x7528;var&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x4F46;&#x5E76;&#x672A;&#x5BF9;&#x5176;&#x8D4B;&#x503C;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x5C31;&#x662F;undefined&#x3002;<br>&#x800C;b&#x7531;&#x4E8E;&#x672A;&#x58F0;&#x660E;&#x5C06;&#x62A5;&#x9519;&#x3002;&#x672A;&#x7533;&#x660E;&#x7684;&#x53D8;&#x91CF;&#x548C;&#x58F0;&#x660E;&#x4E86;&#x672A;&#x8D4B;&#x503C;&#x7684;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
</blockquote>
<h3 id="typeof"><a href="#typeof" class="headerlink" title="typeof"></a>typeof</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="literal">null</span>;</div><div class="line">alert(<span class="keyword">typeof</span> a); <span class="comment">//object</span></div></pre></td></tr></table></figure>
<p>&#x89E3;&#x91CA;&#xFF1A;</p>
<blockquote>
<p>null&#x662F;&#x4E00;&#x4E2A;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x503C;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x4E2A;&#x503C;&#x5C31;&#x662F; null&#x3002;<br>&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x7A7A;&#x6307;&#x9488;&#x5BF9;&#x8C61;&#xFF0C;&#x6240;&#x4EE5;&#x7528; typeof &#x68C0;&#x6D4B;&#x4F1A;&#x8FD4;&#x56DE; &#x201C;object&#x201D;&#x3002;</p>
</blockquote>
<h3 id="&#x201C;-&#x201D;-&#x8FD0;&#x7B97;&#x7B26;"><a href="#&#x201C;-&#x201D;-&#x8FD0;&#x7B97;&#x7B26;" class="headerlink" title="&#x201C;==&#x201D; &#x8FD0;&#x7B97;&#x7B26;"></a>&#x201C;==&#x201D; &#x8FD0;&#x7B97;&#x7B26;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> <span class="literal">undefined</span>;</div><div class="line"><span class="literal">undefined</span> == <span class="literal">null</span>; <span class="comment">// true</span></div><div class="line"><span class="number">1</span> == <span class="literal">true</span>;   <span class="comment">// true</span></div><div class="line"><span class="number">2</span> == <span class="literal">true</span>;   <span class="comment">// false</span></div><div class="line"><span class="number">0</span> == <span class="literal">false</span>;  <span class="comment">// true</span></div><div class="line"><span class="number">0</span> == <span class="string">&apos;&apos;</span>;     <span class="comment">// true</span></div><div class="line"><span class="literal">NaN</span> == <span class="literal">NaN</span>;  <span class="comment">// false</span></div><div class="line">[] == <span class="literal">false</span>; <span class="comment">// true</span></div><div class="line">[] == ![];   <span class="comment">// true</span></div></pre></td></tr></table></figure>
<blockquote>
<p>undefined &#x4E0E; null &#x76F8;&#x7B49;&#xFF0C;&#x4F46;&#x4E0D;&#x6052;&#x7B49;&#xFF08;===&#xFF09;<br>&#x4E00;&#x4E2A;&#x662F; number &#x4E00;&#x4E2A;&#x662F;string&#x65F6;&#xFF0C;&#x4F1A;&#x5C1D;&#x8BD5;&#x5C06; string &#x8F6C;&#x6362;&#x4E3A; number<br>&#x5C1D;&#x8BD5;&#x5C06; boolean &#x8F6C;&#x6362;&#x4E3A;number&#xFF0C;0&#x6216;1<br>&#x5C1D;&#x8BD5;&#x5C06; Object &#x8F6C;&#x6362;&#x6210; number &#x6216; string &#xFF0C;&#x53D6;&#x51B3;&#x4E8E;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x5BF9;&#x6BD4;&#x91CF;&#x7684;&#x7C7B;&#x578B;<br>&#x6240;&#x4EE5;&#xFF0C;&#x5BF9;&#x4E8E;0&#x3001;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5224;&#x65AD;&#xFF0C;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528; &#x201C;===&#x201D;<br>&#x201C;===&#x201D;&#x4F1A;&#x5148;&#x5224;&#x65AD;&#x4E24;&#x8FB9;&#x7684;&#x503C;&#x7C7B;&#x578B;&#xFF0C;&#x7C7B;&#x578B;&#x4E0D;&#x5339;&#x914D;&#x65F6;&#x4E3A; false&#x3002;</p>
</blockquote>
<h3 id="&#x7C7B;&#x578B;&#x8F6C;&#x6362;"><a href="#&#x7C7B;&#x578B;&#x8F6C;&#x6362;" class="headerlink" title="&#x7C7B;&#x578B;&#x8F6C;&#x6362;"></a>&#x7C7B;&#x578B;&#x8F6C;&#x6362;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> foo = <span class="string">&quot;11&quot;</span> + <span class="number">2</span> - <span class="string">&quot;1&quot;</span>;</div><div class="line"><span class="built_in">console</span>.log(foo);</div><div class="line"><span class="built_in">console</span>.log(<span class="keyword">typeof</span> foo);</div></pre></td></tr></table></figure>
<p>&#x6267;&#x884C;&#x5B8C;&#x540E;foo&#x7684;&#x503C;&#x4E3A;111&#xFF0C;foo&#x7684;&#x7C7B;&#x578B;&#x4E3A;String&#x3002;</p>
<h3 id="&#x8BCD;&#x6CD5;&#x4F5C;&#x7528;&#x57DF;"><a href="#&#x8BCD;&#x6CD5;&#x4F5C;&#x7528;&#x57DF;" class="headerlink" title="&#x8BCD;&#x6CD5;&#x4F5C;&#x7528;&#x57DF;"></a>&#x8BCD;&#x6CD5;&#x4F5C;&#x7528;&#x57DF;</h3><h4 id="1"><a href="#1" class="headerlink" title="(1)"></a>(1)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span> (i = <span class="number">0</span>, j = <span class="number">0</span>; i &lt; <span class="number">10</span>, j &lt; <span class="number">6</span>; i++, j++) {</div><div class="line">  k = i + j;</div><div class="line">}</div></pre></td></tr></table></figure>
<h4 id="2"><a href="#2" class="headerlink" title="(2)"></a>(2)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">f1</span>(<span class="params"></span>)</span>{</div><div class="line">  <span class="keyword">var</span> tmp = <span class="number">1</span>;</div><div class="line">  <span class="keyword">this</span>.x = <span class="number">3</span>;</div><div class="line">  <span class="built_in">console</span>.log(tmp);    <span class="comment">//A</span></div><div class="line">  <span class="built_in">console</span>.log(<span class="keyword">this</span>.x)&#xFF1B;<span class="comment">//B</span></div><div class="line">}</div><div class="line"><span class="keyword">var</span> obj = <span class="keyword">new</span> f1(); <span class="comment">//1</span></div><div class="line"><span class="built_in">console</span>.log(obj.x) <span class="comment">//2</span></div><div class="line"><span class="built_in">console</span>.log(f1()); <span class="comment">//3</span></div></pre></td></tr></table></figure>
<blockquote>
<p>&#x8FD9;&#x91CC;&#x5B9E;&#x4F8B;&#x8BDD;&#x5316;&#x4E86; f1 &#x8FD9;&#x4E2A;&#x7C7B;&#x3002;&#x76F8;&#x5F53;&#x4E8E;&#x6267;&#x884C;&#x4E86; f1 &#x51FD;&#x6570;&#x3002;&#x6240;&#x4EE5;&#x8FD9;&#x4E2A;&#x65F6;&#x5019; A &#x4F1A;&#x8F93;&#x51FA; 1<br>&#x800C; B &#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x7684; this &#x4EE3;&#x8868;&#x7684;&#x662F;&#x5B9E;&#x4F8B;&#x5316;&#x7684;&#x5F53;&#x524D;&#x5BF9;&#x8C61; obj B &#x8F93;&#x51FA; 3&#x3002;&#x4EE3;&#x7801;&#xFF08;2&#xFF09;&#x6BCB;&#x5EB8;&#x7F6E;&#x7591;&#x4F1A;&#x8F93;&#x51FA; 3.<br>&#x91CD;&#x70B9; &#x4EE3;&#x7801;&#xFF08;3&#xFF09;&#x9996;&#x5148;&#x8FD9;&#x91CC;&#x5C06;&#x4E0D;&#x518D;&#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x5B83;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;&#x90A3;&#x4E48; A &#x8F93;&#x51FA; 1&#xFF0C;B&#x5462;&#xFF1F;<br>&#x8FD9;&#x91CC;&#x7684;this &#x4EE3;&#x8868;&#x7684;&#x5176;&#x5B9E;&#x5C31;&#x662F; window &#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48; this.x &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5168;&#x5C40;&#x53D8;&#x91CF;,&#x76F8;&#x5F53;&#x4E8E;&#x5728;&#x5916;&#x90E8;&#x7684;&#x4E00;&#x4E2A;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x3002;&#x6240;&#x4EE5; B &#x8F93;&#x51FA; 3&#x3002;<br>&#x6700;&#x540E;&#x4EE3;&#x7801;&#x7531;&#x4E8E; f &#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x90A3;&#x4E48;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5982;&#x679C;&#x6CA1;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x8BDD;&#xFF0C;&#x5C06;&#x4F1A;&#x8FD4;&#x56DE; underfined &#xFF0C;<br>&#x6240;&#x4EE5;&#x7B54;&#x6848;&#x5C31;&#x662F;: 1, 3, 3, 1, 3, underfined&#x3002;</p>
</blockquote>
<h4 id="3"><a href="#3" class="headerlink" title="(3)"></a>(3)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="number">6</span>;</div><div class="line">setTimeout(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{    </div><div class="line">  <span class="keyword">var</span> a = <span class="number">666</span>;</div><div class="line">  alert(a);      <span class="comment">// &#x8F93;&#x51FA;666&#xFF0C;</span></div><div class="line">}, <span class="number">1000</span>);</div></pre></td></tr></table></figure>
<blockquote>
<p>&#x56E0;&#x4E3A;var a = 666;&#x5B9A;&#x4E49;&#x4E86;&#x5C40;&#x90E8;&#x53D8;&#x91CF;a&#xFF0C;&#x5E76;&#x4E14;&#x8D4B;&#x503C;&#x4E3A;666&#xFF0C;&#x6839;&#x636E;&#x53D8;&#x91CF;&#x4F5C;&#x7528;&#x57DF;&#x94FE;&#xFF0C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x5904;&#x5728;&#x4F5C;&#x7528;&#x57DF;&#x672B;&#x7AEF;&#xFF0C;&#x4F18;&#x5148;&#x8BBF;&#x95EE;&#x4E86;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF0C;&#x4ECE;&#x800C;&#x8986;&#x76D6;&#x4E86;&#x5168;&#x5C40;&#x53D8;&#x91CF; &#x3002;</p>
</blockquote>
<h4 id="4"><a href="#4" class="headerlink" title="(4)"></a>(4)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="number">6</span>;</div><div class="line">setTimeout(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{    </div><div class="line">  alert(a);  <span class="comment">// &#x8F93;&#x51FA;undefined </span></div><div class="line">  <span class="keyword">var</span> a = <span class="number">666</span>;</div><div class="line">}, <span class="number">1000</span>);</div></pre></td></tr></table></figure>
<h4 id="5"><a href="#5" class="headerlink" title="(5)"></a>(5)</h4><blockquote>
<p>&#x56E0;&#x4E3A;var a = 666;&#x5B9A;&#x4E49;&#x4E86;&#x5C40;&#x90E8;&#x53D8;&#x91CF;a&#xFF0C;&#x540C;&#x6837;&#x8986;&#x76D6;&#x4E86;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x662F;&#x5728;alert(a);&#x4E4B;&#x524D;a&#x5E76;&#x672A;&#x8D4B;&#x503C;&#xFF0C;&#x6240;&#x4EE5;&#x8F93;&#x51FA;undefined&#x3002;</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="number">6</span>; </div><div class="line">setTimeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    alert(a);</div><div class="line">    <span class="keyword">var</span> a = <span class="number">66</span>; </div><div class="line">}, <span class="number">1000</span>);</div><div class="line">a = <span class="number">666</span>; </div><div class="line">alert(a); </div><div class="line"><span class="comment">// 666, undefined;</span></div></pre></td></tr></table></figure>
<p>&#x8BB0;&#x4F4F;&#xFF1A; &#x5F02;&#x6B65;&#x5904;&#x7406;&#xFF0C;&#x4E00;&#x5207; OK &#x58F0;&#x660E;&#x63D0;&#x524D;</p>
<h4 id="5-1"><a href="#5-1" class="headerlink" title="(5)"></a>(5)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">setN</span>(<span class="params">obj</span>)</span>{</div><div class="line">  obj.name=<span class="string">&apos;&#x5C4C;&#x4E1D;&apos;</span>;</div><div class="line">  obj = <span class="keyword">new</span> <span class="built_in">Object</span>(); </div><div class="line">  obj.name = <span class="string">&apos;&#x8150;&#x5973;&apos;</span>;</div><div class="line">};</div><div class="line"><span class="keyword">var</span> per = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line">setN(per);</div><div class="line">alert(per.name);  <span class="comment">//&#x5C4C;&#x4E1D; &#x5185;&#x90E8;</span></div></pre></td></tr></table></figure>
<h4 id="6"><a href="#6" class="headerlink" title="(6)"></a>(6)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> foo = <span class="number">1</span>;</div><div class="line">(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="built_in">console</span>.log(foo);</div><div class="line">    <span class="keyword">var</span> foo = <span class="number">2</span>;</div><div class="line">    <span class="built_in">console</span>.log(foo);</div><div class="line">})();</div></pre></td></tr></table></figure>
<blockquote>
<p>&#x8F93;&#x51FA;undefined &#x548C; 2&#x3002;</p>
</blockquote>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x76F8;&#x5F53;&#x4E8E;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> foo = <span class="number">1</span>;</div><div class="line">(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="keyword">var</span> foo;</div><div class="line">    <span class="built_in">console</span>.log(foo); <span class="comment">//undefined</span></div><div class="line">    foo = <span class="number">2</span>;</div><div class="line">    <span class="built_in">console</span>.log(foo); <span class="comment">// 2;   </span></div><div class="line">})();</div></pre></td></tr></table></figure>
<blockquote>
<p>&#x51FD;&#x6570;&#x58F0;&#x660E;&#x4E0E;&#x53D8;&#x91CF;&#x58F0;&#x660E;&#x4F1A;&#x88AB;JavaScript&#x5F15;&#x64CE;&#x9690;&#x5F0F;&#x5730;&#x63D0;&#x5347;&#x5230;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x9876;&#x90E8;<br>&#x4F46;&#x662F;&#x53EA;&#x63D0;&#x5347;&#x540D;&#x79F0;&#x4E0D;&#x4F1A;&#x63D0;&#x5347;&#x8D4B;&#x503C;&#x90E8;&#x5206;</p>
</blockquote>
<h4 id="7"><a href="#7" class="headerlink" title="(7)"></a>(7)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">foo</span>(<span class="params"></span>)</span>{</div><div class="line">    foo.a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{ alert(<span class="number">1</span>); }; </div><div class="line">    <span class="keyword">this</span>.a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{ alert(<span class="number">2</span>); };</div><div class="line">    a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{ alert(<span class="number">3</span>); };</div><div class="line">    <span class="keyword">var</span> a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{ alert(<span class="number">4</span>); };</div><div class="line">}; </div><div class="line">foo.prototype.a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{alert(<span class="number">5</span>);};</div><div class="line">foo.a = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{alert(<span class="number">6</span>);};</div><div class="line">foo.a(); <span class="comment">//6</span></div><div class="line"><span class="keyword">var</span> obj = <span class="keyword">new</span> foo();</div><div class="line">obj.a(); <span class="comment">//2</span></div><div class="line">foo.a(); <span class="comment">//1</span></div></pre></td></tr></table></figure>
<h4 id="7-1"><a href="#7-1" class="headerlink" title="(7)"></a>(7)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="number">5</span>; </div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">test</span>(<span class="params"></span>)</span>{</div><div class="line">    a = <span class="number">0</span>; </div><div class="line">    alert(a); </div><div class="line">    alert(<span class="keyword">this</span>.a); <span class="comment">//&#x6CA1;&#x6709;&#x5B9A;&#x4E49; a&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;</span></div><div class="line">    <span class="keyword">var</span> a; </div><div class="line">    alert(a)</div><div class="line">}</div><div class="line">test(); <span class="comment">// 0, 5, 0</span></div><div class="line"><span class="keyword">new</span> test(); <span class="comment">// 0, undefined, 0 //&#x7531;&#x4E8E;&#x7C7B;&#x5B83;&#x81EA;&#x8EAB;&#x6CA1;&#x6709;&#x5C5E;&#x6027;a&#xFF0C; &#x6240;&#x4EE5;&#x662F;undefined</span></div></pre></td></tr></table></figure>
<h3 id="&#x5F15;&#x7528;&#x7C7B;&#x578B;"><a href="#&#x5F15;&#x7528;&#x7C7B;&#x578B;" class="headerlink" title="&#x5F15;&#x7528;&#x7C7B;&#x578B;"></a>&#x5F15;&#x7528;&#x7C7B;&#x578B;</h3><h4 id="1-1"><a href="#1-1" class="headerlink" title="(1)"></a>(1)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line">a.value = <span class="number">1</span>;</div><div class="line">b = a;</div><div class="line">b.value = <span class="number">2</span>;</div><div class="line">alert(a.value); <span class="comment">// 2</span></div></pre></td></tr></table></figure>
<h4 id="2-1"><a href="#2-1" class="headerlink" title="(2)"></a>(2)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> o1 = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line"><span class="keyword">var</span> o2 = o1;</div><div class="line">o2.name = <span class="string">&quot;CSSer&quot;</span>;</div><div class="line"><span class="built_in">console</span>.log(o1.name);</div></pre></td></tr></table></figure>
<blockquote>
<p>&#x5982;&#x679C;&#x4E0D;&#x770B;&#x7B54;&#x6848;&#xFF0C;&#x4F60;&#x56DE;&#x7B54;&#x771F;&#x786E;&#x4E86;&#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48;&#x8BF4;&#x660E;&#x4F60;&#x5BF9;javascript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4E86;&#x89E3;&#x7684;&#x8FD8;&#x662F;&#x6BD4;&#x8F83;&#x6E05;&#x695A;&#x4E86;&#x3002;js&#x4E2D;&#x6709;&#x4E24;&#x79CD;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5206;&#x522B;&#x662F;&#xFF1A;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF08;object Array&#xFF09;&#x3002;&#x5BF9;&#x4E8E;&#x4FDD;&#x5B58;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x503C;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x53D8;&#x91CF;&#x662F;&#x6309;&#x503C;&#x8BBF;&#x95EE;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x64CD;&#x4F5C;&#x7684;&#x662F;&#x53D8;&#x91CF;&#x5B9E;&#x9645;&#x4FDD;&#x5B58;&#x7684;&#x503C;&#x3002;&#x5BF9;&#x4E8E;&#x4FDD;&#x5B58;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x503C;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x53D8;&#x91CF;&#x662F;&#x6309;&#x5F15;&#x7528;&#x8BBF;&#x95EE;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x64CD;&#x4F5C;&#x7684;&#x662F;&#x53D8;&#x91CF;&#x503C;&#x6240;&#x5F15;&#x7528;&#xFF08;&#x6307;&#x5411;&#xFF09;&#x7684;&#x5BF9;&#x8C61;&#x3002;&#x7B54;&#x6848;&#x5C31;&#x6E05;&#x695A;&#x4E86;&#xFF1A;  //CSSer;</p>
</blockquote>
<h4 id="3-1"><a href="#3-1" class="headerlink" title="(3)"></a>(3)</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">changeObjectProperty</span> (<span class="params">o</span>) </span>{</div><div class="line">  o.siteUrl = <span class="string">&quot;http://www.csser.com/&quot;</span>;</div><div class="line">  o = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line">  o.siteUrl = <span class="string">&quot;http://www.popcg.com/&quot;</span>;</div><div class="line">}</div><div class="line"><span class="keyword">var</span> CSSer = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line">changeObjectProperty(CSSer);</div><div class="line"><span class="built_in">console</span>.log(CSSer.siteUrl); <span class="comment">//</span></div></pre></td></tr></table></figure>
<p>&#x5982;&#x679C;CSSer&#x53C2;&#x6570;&#x662F;&#x6309;&#x5F15;&#x7528;&#x4F20;&#x9012;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x7ED3;&#x679C;&#x5E94;&#x8BE5;&#x662F;<code>http://www.popcg.com/</code>&#xFF0C;&#x4F46;&#x5B9E;&#x9645;&#x7ED3;&#x679C;&#x5374;&#x4ECD;&#x662F;<code>http://www.csser.com/</code>&#x3002;&#x4E8B;&#x5B9E;&#x662F;&#x8FD9;&#x6837;&#x7684;&#xFF1A;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x4FEE;&#x6539;&#x4E86;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x503C;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x8BE5;&#x53C2;&#x6570;&#x503C;&#x7684;&#x539F;&#x59CB;&#x5F15;&#x7528;&#x4FDD;&#x6301;&#x4E0D;&#x53D8;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x628A;&#x53C2;&#x6570;&#x60F3;&#x8C61;&#x6210;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF0C;&#x5F53;&#x53C2;&#x6570;&#x88AB;&#x91CD;&#x5199;&#x65F6;&#xFF0C;&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x5F15;&#x7528;&#x7684;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF0C;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x751F;&#x5B58;&#x671F;&#x4EC5;&#x9650;&#x4E8E;&#x51FD;&#x6570;&#x6267;&#x884C;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x51FD;&#x6570;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#xFF0C;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x5373;&#x88AB;&#x9500;&#x6BC1;&#x4EE5;&#x91CA;&#x653E;&#x5185;&#x5B58;&#x3002;    </p>
<blockquote>
<p>&#x8865;&#x5145;&#xFF1A;&#x5185;&#x90E8;&#x73AF;&#x5883;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4F5C;&#x7528;&#x57DF;&#x94FE;&#x8BBF;&#x95EE;&#x6240;&#x6709;&#x7684;&#x5916;&#x90E8;&#x73AF;&#x5883;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x5916;&#x90E8;&#x73AF;&#x5883;&#x65E0;&#x6CD5;&#x8BBF;&#x95EE;&#x5185;&#x90E8;&#x73AF;&#x5883;&#x3002;<br>&#x6BCF;&#x4E2A;&#x73AF;&#x5883;&#x90FD;&#x53EF;&#x4EE5;&#x5411;&#x4E0A;&#x641C;&#x7D22;&#x4F5C;&#x7528;&#x57DF;&#x94FE;&#xFF0C;&#x4EE5;&#x67E5;&#x8BE2;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x540D;&#xFF0C;&#x53CD;&#x4E4B;&#x5411;&#x4E0B;&#x5219;&#x4E0D;&#x80FD;&#x3002;</p>
</blockquote>
<h3 id="JS&#x7684;&#x7EE7;&#x627F;&#x6027;"><a href="#JS&#x7684;&#x7EE7;&#x627F;&#x6027;" class="headerlink" title="JS&#x7684;&#x7EE7;&#x627F;&#x6027;"></a>JS&#x7684;&#x7EE7;&#x627F;&#x6027;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">window</span>.color = <span class="string">&apos;red&apos;</span>;</div><div class="line"><span class="keyword">var</span> o = {<span class="attr">color</span>: <span class="string">&apos;blue&apos;</span>};</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">sayColor</span>(<span class="params"></span>)</span>{</div><div class="line">  alert(<span class="keyword">this</span>.color);</div><div class="line">}</div><div class="line">sayColor(); <span class="comment">//red</span></div><div class="line">sayColor.call(<span class="keyword">this</span>); <span class="comment">//red this-window&#x5BF9;&#x8C61;</span></div><div class="line">sayColor.call(<span class="built_in">window</span>); <span class="comment">//red</span></div><div class="line">sayColor.call(o); <span class="comment">//blue</span></div></pre></td></tr></table></figure>
<h3 id="&#x7CBE;&#x5EA6;&#x95EE;&#x9898;-JS-&#x7CBE;&#x5EA6;&#x4E0D;&#x80FD;&#x7CBE;&#x786E;&#x5230;-0-1"><a href="#&#x7CBE;&#x5EA6;&#x95EE;&#x9898;-JS-&#x7CBE;&#x5EA6;&#x4E0D;&#x80FD;&#x7CBE;&#x786E;&#x5230;-0-1" class="headerlink" title="&#x7CBE;&#x5EA6;&#x95EE;&#x9898;: JS &#x7CBE;&#x5EA6;&#x4E0D;&#x80FD;&#x7CBE;&#x786E;&#x5230; 0.1"></a>&#x7CBE;&#x5EA6;&#x95EE;&#x9898;: JS &#x7CBE;&#x5EA6;&#x4E0D;&#x80FD;&#x7CBE;&#x786E;&#x5230; 0.1</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> n = <span class="number">0.3</span>,m = <span class="number">0.2</span>, i = <span class="number">0.2</span>, j = <span class="number">0.1</span>;</div><div class="line">alert((n - m) == (i - j)); <span class="comment">//false</span></div><div class="line">alert((n-m) == <span class="number">0.1</span>); <span class="comment">//false</span></div><div class="line">alert((i-j)==<span class="number">0.1</span>); <span class="comment">//true</span></div></pre></td></tr></table></figure>
<h3 id="&#x52A0;&#x51CF;&#x8FD0;&#x7B97;"><a href="#&#x52A0;&#x51CF;&#x8FD0;&#x7B97;" class="headerlink" title="&#x52A0;&#x51CF;&#x8FD0;&#x7B97;"></a>&#x52A0;&#x51CF;&#x8FD0;&#x7B97;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">alert(<span class="string">&apos;5&apos;</span>+<span class="number">3</span>); <span class="comment">//53 string</span></div><div class="line">alert(<span class="string">&apos;5&apos;</span>+<span class="string">&apos;3&apos;</span>); <span class="comment">//53 string</span></div><div class="line">alert(<span class="string">&apos;5&apos;</span><span class="number">-3</span>); <span class="comment">//2 number</span></div><div class="line">alert(<span class="string">&apos;5&apos;</span>-<span class="string">&apos;3&apos;</span>); <span class="comment">//2 number</span></div></pre></td></tr></table></figure>
<h3 id="foo-foo-bar"><a href="#foo-foo-bar" class="headerlink" title="foo = foo||bar"></a>foo = foo||bar</h3><p>foo = foo||bar&#xFF0C;&#x8FD9;&#x884C;&#x4EE3;&#x7801;&#x662F;&#x4EC0;&#x4E48;&#x610F;&#x601D;&#xFF1F;&#x4E3A;&#x4EC0;&#x4E48;&#x8981;&#x8FD9;&#x6837;&#x5199;&#xFF1F;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">if</span>(!foo) foo = bar; <span class="comment">//&#x5982;&#x679C;foo&#x5B58;&#x5728;&#xFF0C;&#x503C;&#x4E0D;&#x53D8;&#xFF0C;&#x5426;&#x5219;&#x628A;bar&#x7684;&#x503C;&#x8D4B;&#x7ED9;foo</span></div></pre></td></tr></table></figure>
<p>&#x77ED;&#x8DEF;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;</p>
<blockquote>
<p>&#x4F5C;&#x4E3A; &#x201C;&amp;&amp;&#x201D; &#x548C; &#x201C;||&#x201D; &#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x64CD;&#x4F5C;&#x6570;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x8FD9;&#x4E9B;&#x8868;&#x8FBE;&#x5F0F;&#x5728;&#x8FDB;&#x884C;&#x6C42;&#x503C;&#x65F6;&#xFF0C;&#x53EA;&#x8981;&#x6700;&#x7EC8;&#x7684;&#x7ED3;&#x679C;&#x5DF2;&#x7ECF;&#x53EF;&#x4EE5;&#x786E;&#x5B9A;&#x662F;&#x771F;&#x6216;&#x5047;&#xFF0C;&#x6C42;&#x503C;&#x8FC7;&#x7A0B;&#x4FBF;&#x544A;&#x7EC8;&#x6B62;&#xFF0C;&#x8FD9;&#x79F0;&#x4E4B;&#x4E3A;&#x77ED;&#x8DEF;&#x6C42;&#x503C;&#x3002;</p>
</blockquote>
<h3 id="&#x95ED;&#x5305;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;"><a href="#&#x95ED;&#x5305;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;" class="headerlink" title="&#x95ED;&#x5305;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;"></a>&#x95ED;&#x5305;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">1</span>;i&lt;=<span class="number">3</span>;i++){</div><div class="line">  setTimeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">      <span class="built_in">console</span>.log(i);    </div><div class="line">  },<span class="number">0</span>);  </div><div class="line">};</div></pre></td></tr></table></figure>
<blockquote>
<p>&#x7ED3;&#x679C;&#xFF1A;4 4 4<br>&#x539F;&#x56E0;&#xFF1A;JavaScript &#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x5668;&#x5728;&#x7EBF;&#x7A0B;&#x7A7A;&#x95F2;&#x4E4B;&#x524D;&#x4E0D;&#x4F1A;&#x8FD0;&#x884C;&#x3002;&#x5982;&#x4F55;&#x8BA9;&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x8F93;&#x51FA;1 2 3&#xFF1F;</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">1</span>;i&lt;=<span class="number">3</span>;i++){</div><div class="line">   setTimeout((<span class="function"><span class="keyword">function</span>(<span class="params">a</span>)</span>{  <span class="comment">//&#x6539;&#x6210;&#x7ACB;&#x5373;&#x6267;&#x884C;&#x51FD;&#x6570;</span></div><div class="line">       <span class="built_in">console</span>.log(a);    </div><div class="line">   })(i), <span class="number">0</span>);  </div><div class="line">};</div></pre></td></tr></table></figure>
<h3 id="a-&#x548C;-a"><a href="#a-&#x548C;-a" class="headerlink" title="++a &#x548C; a++"></a>++a &#x548C; a++</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> a=<span class="number">10</span>, b=<span class="number">20</span> , c=<span class="number">30</span>;</div><div class="line">++a;</div><div class="line">a++;</div><div class="line">e=++a+(++b)+(c++)+a++;</div><div class="line">alert(e); <span class="comment">// 77</span></div></pre></td></tr></table></figure>
<h3 id="&#x65E5;&#x671F;&#x51FD;&#x6570;"><a href="#&#x65E5;&#x671F;&#x51FD;&#x6570;" class="headerlink" title="&#x65E5;&#x671F;&#x51FD;&#x6570;"></a>&#x65E5;&#x671F;&#x51FD;&#x6570;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">DateDemo</span> (<span class="params"></span>) </span>{</div><div class="line">  <span class="keyword">var</span> d, s=<span class="string">&quot;&#x4ECA;&#x5929;&#x65E5;&#x671F;&#x662F;&#xFF1A;&quot;</span>;</div><div class="line">  d = <span class="keyword">new</span> <span class="built_in">Date</span>();</div><div class="line">  s += d.getMonth() +<span class="number">1</span>+ <span class="string">&quot;/&quot;</span>;</div><div class="line">  s += d.getDate() + <span class="string">&quot;/&quot;</span>;</div><div class="line">  s += d.getFullYear();</div><div class="line">  <span class="keyword">return</span> s;</div><div class="line">}</div></pre></td></tr></table></figure>
<blockquote>
<p>k &#x7684;&#x7ED3;&#x679C;&#xFF1A;10</p>
</blockquote>
<h3 id="&#x6570;&#x7EC4;-concat-&#x65B9;&#x6CD5;"><a href="#&#x6570;&#x7EC4;-concat-&#x65B9;&#x6CD5;" class="headerlink" title="&#x6570;&#x7EC4; concat() &#x65B9;&#x6CD5;"></a>&#x6570;&#x7EC4; concat() &#x65B9;&#x6CD5;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> arr = <span class="keyword">new</span> <span class="built_in">Array</span>(<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>);</div><div class="line">arr[<span class="number">4</span>]=<span class="string">&apos;z&apos;</span>;</div><div class="line">arr2 = arr.reverse();</div><div class="line">arr3 = arr.concat(arr2);</div><div class="line">alert(arr3); <span class="comment">// z,,5,3,1,z,,5,3,1</span></div></pre></td></tr></table></figure>
<h2 id="23&#x3001;&#x7F16;&#x7A0B;&#x9898;"><a href="#23&#x3001;&#x7F16;&#x7A0B;&#x9898;" class="headerlink" title="23&#x3001;&#x7F16;&#x7A0B;&#x9898;"></a>23&#x3001;&#x7F16;&#x7A0B;&#x9898;</h2><h3 id="&#x8BA1;&#x7B97;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x8282;&#x6570;"><a href="#&#x8BA1;&#x7B97;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x8282;&#x6570;" class="headerlink" title="&#x8BA1;&#x7B97;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x8282;&#x6570;"></a>&#x8BA1;&#x7B97;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x8282;&#x6570;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">new</span> <span class="function"><span class="keyword">function</span>(<span class="params">s</span>)</span>{ </div><div class="line">   <span class="keyword">if</span>(!<span class="built_in">arguments</span>.length||!s) <span class="keyword">return</span> <span class="literal">null</span>;  </div><div class="line">   <span class="keyword">if</span>(<span class="string">&quot;&quot;</span>==s) <span class="keyword">return</span> <span class="number">0</span>;     </div><div class="line">   <span class="keyword">var</span> l=<span class="number">0</span>;</div><div class="line">   <span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">0</span>;i&lt;s.length;i++){        </div><div class="line">       <span class="keyword">if</span>(s.charCodeAt(i)&gt;<span class="number">255</span>) l+=<span class="number">2</span>; <span class="keyword">else</span> l+=<span class="number">1</span>;  <span class="comment">//charCodeAt()&#x5F97;&#x5230;&#x7684;&#x662F;unCode&#x7801;   </span></div><div class="line">   }     <span class="comment">//&#x6C49;&#x5B57;&#x7684;unCode&#x7801;&#x5927;&#x4E8E; 255bit &#x5C31;&#x662F;&#x4E24;&#x4E2A;&#x5B57;&#x8282;</span></div><div class="line">   alert(l); </div><div class="line">}(<span class="string">&quot;hello world!&quot;</span>);</div></pre></td></tr></table></figure>
<h3 id="join"><a href="#join" class="headerlink" title="join()"></a>join()</h3><p>&#x5DF2;&#x77E5;&#x6570;&#x7EC4; var stringArray = [&#x201C;This&#x201D;, &#x201C;is&#x201D;, &#x201C;Baidu&#x201D;, &#x201C;Campus&#x201D;]; alert &#x51FA;&#x201D;This is Baidu Campus&#x201D;&#x3002;</p>
<blockquote>
<p>alert(stringArray.join(&#x201C; &#x201C;));</p>
</blockquote>
<h3 id="charAt-0-&#x3001;toUpperCase"><a href="#charAt-0-&#x3001;toUpperCase" class="headerlink" title="charAt(0)&#x3001;toUpperCase()"></a>charAt(0)&#x3001;toUpperCase()</h3><p>&#x5DF2;&#x77E5;&#x6709;&#x5B57;&#x7B26;&#x4E32;<code>foo=&quot;get-element-by-id&quot;</code>,&#x5199;&#x4E00;&#x4E2A; function &#x5C06;&#x5176;&#x8F6C;&#x5316;&#x6210;&#x9A7C;&#x5CF0;&#x8868;&#x793A;&#x6CD5; &#x201C;getElementById&#x201D;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">combo</span>(<span class="params">msg</span>)</span>{</div><div class="line">  <span class="keyword">var</span> arr=msg.split(<span class="string">&quot;-&quot;</span>);</div><div class="line">  <span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">1</span>;i&lt;arr.length;i++){</div><div class="line">    arr[i]=arr[i].charAt(<span class="number">0</span>).toUpperCase()+arr[i].substr(<span class="number">1</span>,arr[i].length<span class="number">-1</span>);</div><div class="line">  }</div><div class="line">  msg=arr.join(<span class="string">&quot;&quot;</span>);</div><div class="line">  <span class="keyword">return</span> msg;</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="&#x6570;&#x7EC4;&#x5012;&#x6392;"><a href="#&#x6570;&#x7EC4;&#x5012;&#x6392;" class="headerlink" title="&#x6570;&#x7EC4;&#x5012;&#x6392;"></a>&#x6570;&#x7EC4;&#x5012;&#x6392;</h3><p><code>var numberArray = [3,6,2,4,1,5];</code></p>
<p>1) &#x5B9E;&#x73B0;&#x5BF9;&#x8BE5;&#x6570;&#x7EC4;&#x7684;&#x5012;&#x6392;&#xFF0C;&#x8F93;&#x51FA;[5,1,4,2,6,3]</p>
<blockquote>
<p>numberArray.reverse()</p>
</blockquote>
<p>2) &#x5B9E;&#x73B0;&#x5BF9;&#x8BE5;&#x6570;&#x7EC4;&#x7684;&#x964D;&#x5E8F;&#x6392;&#x5217;&#xFF0C;&#x8F93;&#x51FA;[6,5,4,3,2,1]</p>
<blockquote>
<p>numberArray.sort(function(a,b){return b-a});</p>
</blockquote>
<h3 id="&#x65E5;&#x671F;-Date"><a href="#&#x65E5;&#x671F;-Date" class="headerlink" title="&#x65E5;&#x671F; Date()"></a>&#x65E5;&#x671F; Date()</h3><p>&#x8F93;&#x51FA;&#x4ECA;&#x5929;&#x7684;&#x65E5;&#x671F;&#xFF0C;&#x4EE5; YYYY-MM-DD &#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x6BD4;&#x5982;&#x4ECA;&#x5929;&#x662F; 2015 &#x5E74; 7 &#x6708; 14 &#x65E5;&#xFF0C;&#x5219;&#x8F93;&#x51FA; 2015-07-14</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> d = <span class="keyword">new</span> <span class="built_in">Date</span>();</div><div class="line"><span class="comment">// &#x83B7;&#x53D6;&#x5E74;&#xFF0C;getFullYear()&#x8FD4;&#x56DE;4&#x4F4D;&#x7684;&#x6570;&#x5B57;</span></div><div class="line"><span class="keyword">var</span> year = d.getFullYear();</div><div class="line"><span class="comment">// &#x83B7;&#x53D6;&#x6708;&#xFF0C;&#x6708;&#x4EFD;&#x6BD4;&#x8F83;&#x7279;&#x6B8A;&#xFF0C;0&#x662F;1&#x6708;&#xFF0C;11&#x662F;12&#x6708;</span></div><div class="line"><span class="keyword">var</span> month = d.getMonth() + <span class="number">1</span>;</div><div class="line"><span class="comment">// &#x53D8;&#x6210;&#x4E24;&#x4F4D;</span></div><div class="line">month = month &lt; <span class="number">10</span> ? <span class="string">&apos;0&apos;</span> + month : month;</div><div class="line"><span class="comment">// &#x83B7;&#x53D6;&#x65E5;</span></div><div class="line"><span class="keyword">var</span> day = d.getDate();</div><div class="line">day = day &lt; <span class="number">10</span> ? <span class="string">&apos;0&apos;</span> + day : day;</div><div class="line">alert(year + <span class="string">&apos;-&apos;</span> + month + <span class="string">&apos;-&apos;</span> + day);</div></pre></td></tr></table></figure>
<h3 id="&#x6B63;&#x5219;&#x66FF;&#x6362;"><a href="#&#x6B63;&#x5219;&#x66FF;&#x6362;" class="headerlink" title="&#x6B63;&#x5219;&#x66FF;&#x6362;"></a>&#x6B63;&#x5219;&#x66FF;&#x6362;</h3><p>&#x5C06;&#x5B57;&#x7B26;&#x4E32;<code>&quot;&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$name}&lt;/td&gt;&lt;/tr&gt;&quot;</code>&#x4E2D;&#x7684;<code>{$id}</code>&#x66FF;&#x6362;&#x6210;10&#xFF0C;<code>{$name}</code>&#x66FF;&#x6362;&#x6210; <code>Tony</code> &#xFF08;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#xFF09;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="string">&quot;&lt;tr&gt;&lt;td&gt;{$id}&lt;/td&gt;&lt;td&gt;{$id}_{$name}&lt;/td&gt;&lt;/tr&gt;&quot;</span>.replace(<span class="regexp">/{\$id}/g</span>, <span class="string">&apos;10&apos;</span>).replace(<span class="regexp">/{\$name}/g</span>, <span class="string">&apos;Tony&apos;</span>);</div></pre></td></tr></table></figure>
<h3 id="&#x8F6C;&#x4E49;"><a href="#&#x8F6C;&#x4E49;" class="headerlink" title="&#x8F6C;&#x4E49;"></a>&#x8F6C;&#x4E49;</h3><p>&#x4E3A;&#x4E86;&#x4FDD;&#x8BC1;&#x9875;&#x9762;&#x8F93;&#x51FA;&#x5B89;&#x5168;&#xFF0C;&#x6211;&#x4EEC;&#x7ECF;&#x5E38;&#x9700;&#x8981;&#x5BF9;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x5B57;&#x7B26;&#x8FDB;&#x884C;&#x8F6C;&#x4E49;&#xFF0C;&#x8BF7;&#x5199;&#x4E00;&#x4E2A;&#x51FD;&#x6570; escapeHtml&#xFF0C;&#x5C06;<code>&lt;, &gt;, &amp;, &#x201C;</code>&#x8FDB;&#x884C;&#x8F6C;&#x4E49;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">escapeHtml</span>(<span class="params">str</span>) </span>{</div><div class="line">  <span class="keyword">return</span> str.replace(<span class="regexp">/[&lt;&gt;&quot;&amp;]/g</span>, <span class="function"><span class="keyword">function</span>(<span class="params">match</span>) </span>{</div><div class="line">    <span class="keyword">switch</span> (match) {</div><div class="line">      <span class="keyword">case</span> <span class="string">&quot;&lt;&quot;</span>:</div><div class="line">        <span class="keyword">return</span> <span class="string">&quot;&amp;lt;&quot;</span>;</div><div class="line">      <span class="keyword">case</span> <span class="string">&quot;&gt;&quot;</span>:</div><div class="line">        <span class="keyword">return</span> <span class="string">&quot;&amp;gt;&quot;</span>;</div><div class="line">      <span class="keyword">case</span> <span class="string">&quot;&amp;&quot;</span>:</div><div class="line">        <span class="keyword">return</span> <span class="string">&quot;&amp;amp;&quot;</span>;</div><div class="line">      <span class="keyword">case</span> <span class="string">&quot;\&quot;&quot;</span>:</div><div class="line">        <span class="keyword">return</span> <span class="string">&quot;&amp;quot;&quot;</span>;</div><div class="line">    }</div><div class="line">  });</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="&#x968F;&#x673A;&#x6570;"><a href="#&#x968F;&#x673A;&#x6570;" class="headerlink" title="&#x968F;&#x673A;&#x6570;"></a>&#x968F;&#x673A;&#x6570;</h3><p>&#x7528; js &#x5B9E;&#x73B0;&#x968F;&#x673A;&#x9009;&#x53D6; 10&#x2013;100 &#x4E4B;&#x95F4;&#x7684; 10 &#x4E2A;&#x6570;&#x5B57;&#xFF0C;&#x5B58;&#x5165;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#xFF0C;&#x5E76;&#x6392;&#x5E8F;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">randomNub</span>(<span class="params">aArray, len, min, max</span>) </span>{</div><div class="line">  <span class="keyword">if</span> (len &gt;= (max - min)) {</div><div class="line">    <span class="keyword">return</span> <span class="string">&apos;&#x8D85;&#x8FC7;&apos;</span> + min + <span class="string">&apos;-&apos;</span> + max + <span class="string">&apos;&#x4E4B;&#x95F4;&#x7684;&#x4E2A;&#x6570;&#x8303;&#x56F4;&apos;</span> + (max - min - <span class="number">1</span>) + <span class="string">&apos;&#x4E2A;&#x7684;&#x603B;&#x6570;&apos;</span>;</div><div class="line">  }</div><div class="line">  <span class="keyword">if</span> (aArray.length &gt;= len) {</div><div class="line">    aArray.sort(<span class="function"><span class="keyword">function</span>(<span class="params">a, b</span>) </span>{</div><div class="line">      <span class="keyword">return</span> a - b</div><div class="line">    });</div><div class="line">    <span class="keyword">return</span> aArray;</div><div class="line">  }</div><div class="line">  <span class="keyword">var</span> nowNub = <span class="built_in">parseInt</span>(<span class="built_in">Math</span>.random() * (max - min - <span class="number">1</span>)) + (min + <span class="number">1</span>);</div><div class="line">  <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span>; j &lt; aArray.length; j++) {</div><div class="line">    <span class="keyword">if</span> (nowNub == aArray[j]) {</div><div class="line">      randomNub(aArray, len, min, max);</div><div class="line">      <span class="keyword">return</span>;</div><div class="line">    }</div><div class="line">  }</div><div class="line">  aArray.push(nowNub);</div><div class="line">  randomNub(aArray, len, min, max);</div><div class="line">  <span class="keyword">return</span> aArray;</div><div class="line">}</div><div class="line"><span class="keyword">var</span> arr=[];</div><div class="line">randomNub(arr,<span class="number">10</span>,<span class="number">10</span>,<span class="number">100</span>);</div></pre></td></tr></table></figure>
<h3 id="&#x751F;&#x6210;5&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x968F;&#x673A;&#x6570;&#xFF1B;"><a href="#&#x751F;&#x6210;5&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x968F;&#x673A;&#x6570;&#xFF1B;" class="headerlink" title="&#x751F;&#x6210;5&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x968F;&#x673A;&#x6570;&#xFF1B;"></a>&#x751F;&#x6210;5&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x968F;&#x673A;&#x6570;&#xFF1B;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//&#x601D;&#x8DEF;&#xFF1A;5&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x6570;&#xFF0C;&#x6BCF;&#x751F;&#x6210;&#x4E00;&#x6B21;&#x5C31;&#x548C;&#x524D;&#x9762;&#x7684;&#x6240;&#x6709;&#x6570;&#x5B57;&#x76F8;&#x6BD4;&#x8F83;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x5219;&#x653E;&#x5F03;&#x5F53;&#x524D;&#x751F;&#x6210;&#x7684;&#x6570;&#x5B57;&#xFF01;</span></div><div class="line"><span class="keyword">var</span> num1 = [];</div><div class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; <span class="number">5</span>; i++){</div><div class="line">    num1[i] = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random()*<span class="number">10</span>) + <span class="number">1</span>; <span class="comment">//&#x8303;&#x56F4;&#x662F; [1, 10]</span></div><div class="line">    <span class="keyword">for</span>(<span class="keyword">var</span> j = <span class="number">0</span>; j &lt; i; j++){</div><div class="line">        <span class="keyword">if</span>(num1[i] == num1[j]){</div><div class="line">            i--;</div><div class="line">        }</div><div class="line">    }</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="&#x5408;&#x5E76;&#x6570;&#x636E;&#x5E76;&#x5220;&#x9664;&#x67D0;&#x4E2A;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x5143;&#x7D20;"><a href="#&#x5408;&#x5E76;&#x6570;&#x636E;&#x5E76;&#x5220;&#x9664;&#x67D0;&#x4E2A;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x5143;&#x7D20;" class="headerlink" title="&#x5408;&#x5E76;&#x6570;&#x636E;&#x5E76;&#x5220;&#x9664;&#x67D0;&#x4E2A;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x5143;&#x7D20;"></a>&#x5408;&#x5E76;&#x6570;&#x636E;&#x5E76;&#x5220;&#x9664;&#x67D0;&#x4E2A;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x5143;&#x7D20;</h3><p>&#x628A;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x5408;&#x5E76;&#xFF0C;&#x5E76;&#x5220;&#x9664;&#x7B2C;&#x4E8C;&#x4E2A;&#x5143;&#x7D20;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> array1 = [<span class="string">&apos;a&apos;</span>,<span class="string">&apos;b&apos;</span>,<span class="string">&apos;c&apos;</span>];</div><div class="line"><span class="keyword">var</span> bArray = [<span class="string">&apos;d&apos;</span>,<span class="string">&apos;e&apos;</span>,<span class="string">&apos;f&apos;</span>];</div><div class="line"><span class="keyword">var</span> cArray = array1.concat(bArray);</div><div class="line">cArray.splice(<span class="number">1</span>,<span class="number">1</span>);</div></pre></td></tr></table></figure>
<h3 id="DOM-&#x8282;&#x70B9;&#x64CD;&#x4F5C;"><a href="#DOM-&#x8282;&#x70B9;&#x64CD;&#x4F5C;" class="headerlink" title="DOM &#x8282;&#x70B9;&#x64CD;&#x4F5C;"></a>DOM &#x8282;&#x70B9;&#x64CD;&#x4F5C;</h3><p>&#x6DFB;&#x52A0;&#x3001;&#x79FB;&#x9664;&#x3001;&#x79FB;&#x52A8;&#x3001;&#x590D;&#x5236;&#x3001;&#x521B;&#x5EFA;&#x548C;&#x67E5;&#x627E;&#x8282;&#x70B9;&#xFF08;&#x539F;&#x751F;JS&#xFF09;</p>
<p>1&#xFF09;&#x521B;&#x5EFA;&#x65B0;&#x8282;&#x70B9;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">document</span>.createDocumentFragment()    <span class="comment">//&#x521B;&#x5EFA;&#x4E00;&#x4E2A;DOM&#x7247;&#x6BB5;</span></div><div class="line"><span class="built_in">document</span>.createElement()   <span class="comment">//&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x5143;&#x7D20;</span></div><div class="line"><span class="built_in">document</span>.createTextNode()   <span class="comment">//&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x6587;&#x672C;&#x8282;&#x70B9;</span></div></pre></td></tr></table></figure>
<p>2&#xFF09;&#x6DFB;&#x52A0;&#x3001;&#x79FB;&#x9664;&#x3001;&#x66FF;&#x6362;&#x3001;&#x63D2;&#x5165;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">domObj.appendChild();    <span class="comment">//&#x6DFB;&#x52A0;</span></div><div class="line">domObj.removeChild();      <span class="comment">//&#x79FB;&#x9664;</span></div><div class="line">domObj.replaceChild();      <span class="comment">//&#x66FF;&#x6362;</span></div><div class="line">domObj.insertBefore();      <span class="comment">//&#x63D2;&#x5165;</span></div></pre></td></tr></table></figure>
<p>3&#xFF09;&#x67E5;&#x627E;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">document</span>.getElementsByTagName()    <span class="comment">//&#x901A;&#x8FC7;&#x6807;&#x7B7E;&#x540D;&#x79F0;</span></div><div class="line"><span class="built_in">document</span>.getElementsByName()     <span class="comment">//&#x901A;&#x8FC7;&#x5143;&#x7D20;&#x7684;Name&#x5C5E;&#x6027;&#x7684;&#x503C;</span></div><div class="line"><span class="built_in">document</span>.getElementById()        <span class="comment">//&#x901A;&#x8FC7;&#x5143;&#x7D20;Id&#xFF0C;&#x552F;&#x4E00;&#x6027;</span></div></pre></td></tr></table></figure>
<h3 id="URL-&#x89E3;&#x6790;&#x6210;-json-&#x5BF9;&#x8C61;"><a href="#URL-&#x89E3;&#x6790;&#x6210;-json-&#x5BF9;&#x8C61;" class="headerlink" title="URL &#x89E3;&#x6790;&#x6210; json &#x5BF9;&#x8C61;"></a>URL &#x89E3;&#x6790;&#x6210; json &#x5BF9;&#x8C61;</h3><p>&#x6709;&#x8FD9;&#x6837;&#x4E00;&#x4E2A; URL&#xFF1A;<code>http://item.taobao.com/item.htm?a=1&amp;b=2&amp;c=&amp;d=xxx&amp;e</code>&#xFF0C;&#x8BF7;&#x5199;&#x4E00;&#x6BB5; JS &#x7A0B;&#x5E8F;&#x63D0;&#x53D6; URL &#x4E2D;&#x7684;&#x5404;&#x4E2A; GET &#x53C2;&#x6570;(&#x53C2;&#x6570;&#x540D;&#x548C;&#x53C2;&#x6570;&#x4E2A;&#x6570;&#x4E0D;&#x786E;&#x5B9A;)&#xFF0C;&#x5C06;&#x5176;&#x6309; key-value &#x5F62;&#x5F0F;&#x8FD4;&#x56DE;&#x5230;&#x4E00;&#x4E2A; json &#x7ED3;&#x6784;&#x4E2D;&#xFF0C;&#x5982; <code>{a:&#x2019;1&#x2032;, b:&#x2019;2&#x2032;, c:&#x201D;, d:&#x2019;xxx&#x2019;, e:undefined}</code>&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">serilizeUrl</span>(<span class="params">url</span>) </span>{</div><div class="line">  <span class="keyword">var</span> urlObject = {};</div><div class="line">  <span class="keyword">if</span> (<span class="regexp">/\?/</span>.test(url)) {</div><div class="line">    <span class="keyword">var</span> urlString = url.substring(url.indexOf(<span class="string">&quot;?&quot;</span>) + <span class="number">1</span>);</div><div class="line">    <span class="keyword">var</span> urlArray = urlString.split(<span class="string">&quot;&amp;&quot;</span>);</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>, len = urlArray.length; i &lt; len; i++) {</div><div class="line">      <span class="keyword">var</span> urlItem = urlArray[i];</div><div class="line">      <span class="keyword">var</span> item = urlItem.split(<span class="string">&quot;=&quot;</span>);</div><div class="line">      urlObject[item[<span class="number">0</span>]] = item[<span class="number">1</span>];</div><div class="line">    }</div><div class="line">    <span class="keyword">return</span> urlObject;</div><div class="line">  }</div><div class="line">  <span class="keyword">return</span> <span class="literal">null</span>;</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x548C;&#x6B63;&#x5219;&#x5B57;&#x9762;&#x91CF;&#x533A;&#x522B;"><a href="#&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x548C;&#x6B63;&#x5219;&#x5B57;&#x9762;&#x91CF;&#x533A;&#x522B;" class="headerlink" title="&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x548C;&#x6B63;&#x5219;&#x5B57;&#x9762;&#x91CF;&#x533A;&#x522B;"></a>&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x548C;&#x6B63;&#x5219;&#x5B57;&#x9762;&#x91CF;&#x533A;&#x522B;</h3><p>&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x6784;&#x9020;&#x51FD;&#x6570;<code>var reg=new RegExp(&quot;xxx&quot;)</code>&#x4E0E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5B57;&#x9762;&#x91CF;<code>var reg=//</code>&#x6709;&#x4EC0;&#x4E48;&#x4E0D;&#x540C;&#xFF0C;&#x5339;&#x914D;&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<blockquote>
<p>&#x5F53;&#x4F7F;&#x7528; RegExp() &#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4E0D;&#x4EC5;&#x9700;&#x8981;&#x8F6C;&#x4E49;&#x5F15;&#x53F7;&#xFF08;&#x5373; \&#x201D; &#x8868;&#x793A; &#x201C;&#xFF09;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x53CC;&#x53CD;&#x659C;&#x6760;&#xFF08;&#x5373;\&#x8868;&#x793A;&#x4E00;&#x4E2A;\&#xFF09;&#x3002;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5B57;&#x9762;&#x91CF;&#x7684;&#x6548;&#x7387;&#x66F4;&#x9AD8;&#x3002; </p>
</blockquote>
<p>&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x5339;&#x914D;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> regMail = <span class="regexp">/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/</span>;</div></pre></td></tr></table></figure>
<h3 id="&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;"><a href="#&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;" class="headerlink" title="&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;"></a>&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;</h3><p>&#x5199;&#x51FA;&#x7B80;&#x5355;&#x63CF;&#x8FF0; html &#x6807;&#x7B7E;&#xFF08;&#x4E0D;&#x5E26;&#x5C5E;&#x6027;&#x7684;&#x5F00;&#x59CB;&#x6807;&#x7B7E;&#x548C;&#x7ED3;&#x675F;&#x6807;&#x7B7E;&#xFF09;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5E76;&#x5C06;<code>var str = &quot;&lt;div&gt;&#x8FD9;&#x91CC;&#x662F;div&lt;p&gt;&#x91CC;&#x9762;&#x7684;&#x6BB5;&#x843D;&lt;/p&gt;&lt;/div&gt;&quot;;</code>&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7684; html &#x6807;&#x7B7E;&#x53BB;&#x9664;&#x6389; </p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> reg = <span class="regexp">/&lt;\/?\w+\/?&gt;/gi</span>;</div><div class="line"><span class="keyword">var</span> str = <span class="string">&quot;&lt;div&gt;&#x8FD9;&#x91CC;&#x662F;div&lt;p&gt;&#x91CC;&#x9762;&#x7684;&#x6BB5;&#x843D;&lt;/p&gt;&lt;/div&gt;&quot;</span>;</div><div class="line">alert(str.replace(reg,<span class="string">&quot; &quot;</span>));</div></pre></td></tr></table></figure>
<h3 id="&#x6E05;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x524D;&#x540E;&#x7684;&#x7A7A;&#x683C;"><a href="#&#x6E05;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x524D;&#x540E;&#x7684;&#x7A7A;&#x683C;" class="headerlink" title="&#x6E05;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x524D;&#x540E;&#x7684;&#x7A7A;&#x683C;"></a>&#x6E05;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x524D;&#x540E;&#x7684;&#x7A7A;&#x683C;</h3><p>&#x5199;&#x4E00;&#x4E2A;function&#xFF0C;&#x6E05;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x524D;&#x540E;&#x7684;&#x7A7A;&#x683C;&#x3002;&#xFF08;&#x517C;&#x5BB9;&#x6240;&#x6709;&#x6D4F;&#x89C8;&#x5668;&#xFF09;&#x4F7F;&#x7528;&#x81EA;&#x5E26;&#x63A5;&#x53E3; trim()&#xFF0C;&#x8003;&#x8651;&#x517C;&#x5BB9;&#x6027;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">if</span> (!<span class="built_in">String</span>.prototype.trim) { </div><div class="line">  <span class="built_in">String</span>.prototype.trim = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{ </div><div class="line">    <span class="keyword">return</span> <span class="keyword">this</span>.replace(<span class="regexp">/^\s+/</span>, <span class="string">&quot;&quot;</span>).replace(<span class="regexp">/\s+$/</span>,<span class="string">&quot;&quot;</span>);</div><div class="line">  }</div><div class="line">}</div><div class="line"><span class="comment">// test the function </span></div><div class="line"><span class="keyword">var</span> str = <span class="string">&quot; \t\n test string &quot;</span>.trim(); </div><div class="line">alert(str == <span class="string">&quot;test string&quot;</span>); <span class="comment">// alerts &quot;true&quot;</span></div></pre></td></tr></table></figure>
<h3 id="Javascript&#x4E2D;-callee-&#x548C;-caller-&#x7684;&#x4F5C;&#x7528;"><a href="#Javascript&#x4E2D;-callee-&#x548C;-caller-&#x7684;&#x4F5C;&#x7528;" class="headerlink" title="Javascript&#x4E2D; callee &#x548C; caller &#x7684;&#x4F5C;&#x7528;"></a>Javascript&#x4E2D; callee &#x548C; caller &#x7684;&#x4F5C;&#x7528;</h3><blockquote>
<p>caller&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5BF9;&#x51FD;&#x6570;&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x8BE5;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x4E86;&#x5F53;&#x524D;&#x51FD;&#x6570;&#xFF1B;<br>callee&#x662F;&#x8FD4;&#x56DE;&#x6B63;&#x5728;&#x88AB;&#x6267;&#x884C;&#x7684; function &#x51FD;&#x6570;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6240;&#x6307;&#x5B9A;&#x7684; function &#x5BF9;&#x8C61;&#x7684;&#x6B63;&#x6587;&#x3002;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x4E00;&#x5BF9;&#x5154;&#x5B50;&#x6BCF;&#x6708;&#x751F;&#x4E00;&#x5BF9;&#x5154;&#x5B50;&#xFF1B;&#x4E00;&#x5BF9;&#x65B0;&#x751F;&#x5154;&#xFF0C;&#x4ECE;&#x7B2C;&#x4E8C;&#x4E2A;&#x6708;&#x8D77;&#x5C31;&#x5F00;&#x59CB;&#x751F;&#x5154;&#x5B50;&#xFF1B;&#x5047;&#x5B9A;&#x6BCF;&#x5BF9;&#x5154;&#x5B50;&#x90FD;&#x662F;&#x4E00;&#x96CC;&#x4E00;&#x96C4;&#xFF0C;&#x8BD5;&#x95EE;&#x4E00;&#x5BF9;&#x5154;&#x5B50;&#xFF0C;&#x7B2C;n&#x4E2A;&#x6708;&#x80FD;&#x7E41;&#x6B96;&#x6210;&#x591A;&#x5C11;&#x5BF9;&#x5154;&#x5B50;&#xFF1F;&#xFF08;&#x4F7F;&#x7528;callee&#x5B8C;&#x6210;&#xFF09;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> result = [];</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params">n</span>) </span>{  <span class="comment">//&#x5178;&#x578B;&#x7684;&#x6590;&#x6CE2;&#x90A3;&#x5951;&#x6570;&#x5217;</span></div><div class="line">  <span class="keyword">if</span> (n == <span class="number">1</span>) {</div><div class="line">    <span class="keyword">return</span> <span class="number">1</span>;</div><div class="line">  } <span class="keyword">else</span> <span class="keyword">if</span> (n == <span class="number">2</span>) {</div><div class="line">    <span class="keyword">return</span> <span class="number">1</span>;</div><div class="line">  } <span class="keyword">else</span> {</div><div class="line">    <span class="keyword">if</span> (result[n]) {</div><div class="line">      <span class="keyword">return</span> result[n];</div><div class="line">    } <span class="keyword">else</span> {</div><div class="line">      <span class="comment">//argument.callee()&#x8868;&#x793A;fn()</span></div><div class="line">      result[n] = <span class="built_in">arguments</span>.callee(n - <span class="number">1</span>) + <span class="built_in">arguments</span>.callee(n - <span class="number">2</span>);</div><div class="line">      <span class="keyword">return</span> result[n];</div><div class="line">    }</div><div class="line">  }</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><a href="#&#x6570;&#x7EC4;&#x53BB;&#x91CD;" class="headerlink" title="&#x6570;&#x7EC4;&#x53BB;&#x91CD;"></a>&#x6570;&#x7EC4;&#x53BB;&#x91CD;</h3><p>&#x65B9;&#x6CD5;&#x4E00;: &#x6BCF;&#x904D;&#x5386;&#x4E00;&#x6B21;&#x5C31;&#x548C;&#x4E4B;&#x524D;&#x7684;&#x6240;&#x6709;&#x505A;&#x6BD4;&#x8F83;&#xFF0C;&#x4E0D;&#x76F8;&#x7B49;&#x5219;&#x653E;&#x5165;&#x65B0;&#x7684;&#x6570;&#x7EC4;&#x4E2D;&#xFF01;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//&#x8FD9;&#x91CC;&#x7528;&#x7684;&#x539F;&#x578B; &#x4E2A;&#x4EBA;&#x505A;&#x6CD5;&#xFF1B;</span></div><div class="line"><span class="built_in">Array</span>.prototype.unique = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">  <span class="keyword">var</span> len = <span class="keyword">this</span>.length,</div><div class="line">    newArr = [],</div><div class="line">    flag = <span class="number">1</span>;</div><div class="line">  <span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; len; i++, flag = <span class="number">1</span>){</div><div class="line">    <span class="keyword">for</span>(<span class="keyword">var</span> j = <span class="number">0</span>; j &lt; i; j++){</div><div class="line">      <span class="keyword">if</span>(<span class="keyword">this</span>[i] == <span class="keyword">this</span>[j]){</div><div class="line">        flag = <span class="number">0</span>;        <span class="comment">//&#x627E;&#x5230;&#x76F8;&#x540C;&#x7684;&#x6570;&#x5B57;&#x540E;&#xFF0C;&#x4E0D;&#x6267;&#x884C;&#x6DFB;&#x52A0;&#x6570;&#x636E;</span></div><div class="line">      }</div><div class="line">    }</div><div class="line">    flag ? newArr.push(<span class="keyword">this</span>[i]) : <span class="string">&apos;&apos;</span>;</div><div class="line">  }</div><div class="line">  <span class="keyword">return</span> newArr;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x65B9;&#x6CD5;&#x4E8C;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> arr=[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">5</span>,<span class="number">6</span>,<span class="number">1</span>,<span class="number">9</span>,<span class="number">3</span>,<span class="number">25</span>,<span class="number">4</span>];</div><div class="line"><span class="built_in">Array</span>.prototype.unique2 = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span></div><div class="line">{</div><div class="line">  <span class="keyword">var</span> n = []; <span class="comment">//&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x4E34;&#x65F6;&#x6570;&#x7EC4;</span></div><div class="line">  <span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; <span class="keyword">this</span>.length; i++) <span class="comment">//&#x904D;&#x5386;&#x5F53;&#x524D;&#x6570;&#x7EC4;</span></div><div class="line">  {</div><div class="line">    <span class="comment">//&#x5982;&#x679C;&#x5F53;&#x524D;&#x6570;&#x7EC4;&#x7684;&#x7B2C;i&#x5DF2;&#x7ECF;&#x4FDD;&#x5B58;&#x8FDB;&#x4E86;&#x4E34;&#x65F6;&#x6570;&#x7EC4;&#xFF0C;&#x90A3;&#x4E48;&#x8DF3;&#x8FC7;&#xFF0C;</span></div><div class="line">    <span class="comment">//&#x5426;&#x5219;&#x628A;&#x5F53;&#x524D;&#x9879;push&#x5230;&#x4E34;&#x65F6;&#x6570;&#x7EC4;&#x91CC;&#x9762;</span></div><div class="line">    <span class="keyword">if</span> (n.indexOf(<span class="keyword">this</span>[i]) == <span class="number">-1</span>) n.push(<span class="keyword">this</span>[i]);</div><div class="line">  }</div><div class="line">  <span class="keyword">return</span> n;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">var</span> newArr2=arr.unique2(arr);</div><div class="line">alert(newArr2); <span class="comment">//&#x8F93;&#x51FA;1,2,3,4,5,6,9,25</span></div></pre></td></tr></table></figure>
<h3 id="&#x9636;&#x4E58;&#x51FD;&#x6570;&#xFF1B;"><a href="#&#x9636;&#x4E58;&#x51FD;&#x6570;&#xFF1B;" class="headerlink" title="&#x9636;&#x4E58;&#x51FD;&#x6570;&#xFF1B;"></a>&#x9636;&#x4E58;&#x51FD;&#x6570;&#xFF1B;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//&#x539F;&#x578B;&#x65B9;&#x6CD5;</span></div><div class="line"><span class="built_in">Number</span>.prototype.N = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="keyword">var</span> re = <span class="number">1</span>;</div><div class="line">    <span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">1</span>; i &lt;= <span class="keyword">this</span>; i++){</div><div class="line">        re *= i;</div><div class="line">    }</div><div class="line">    <span class="keyword">return</span> re;</div><div class="line">}</div><div class="line"><span class="keyword">var</span> num = <span class="number">5</span>;</div><div class="line">alert(num.N());</div></pre></td></tr></table></figure>
<h3 id="&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x51FA;&#x73B0;&#x6B21;&#x6570;&#x6700;&#x591A;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x7EDF;&#x8BA1;&#x8FD9;&#x4E2A;&#x6B21;&#x6570;"><a href="#&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x51FA;&#x73B0;&#x6B21;&#x6570;&#x6700;&#x591A;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x7EDF;&#x8BA1;&#x8FD9;&#x4E2A;&#x6B21;&#x6570;" class="headerlink" title="&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x51FA;&#x73B0;&#x6B21;&#x6570;&#x6700;&#x591A;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x7EDF;&#x8BA1;&#x8FD9;&#x4E2A;&#x6B21;&#x6570;"></a>&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x51FA;&#x73B0;&#x6B21;&#x6570;&#x6700;&#x591A;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x7EDF;&#x8BA1;&#x8FD9;&#x4E2A;&#x6B21;&#x6570;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> str = <span class="string">&apos;asdfssaaasasasasaa&apos;</span>;</div><div class="line"><span class="keyword">var</span> json = {};</div><div class="line"><span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; str.length; i++) {</div><div class="line">  <span class="keyword">if</span>(!json[str.charAt(i)]){</div><div class="line">    json[str.charAt(i)] = <span class="number">1</span>;</div><div class="line">  } <span class="keyword">else</span> {</div><div class="line">    json[str.charAt(i)]++;</div><div class="line">  }</div><div class="line">};</div><div class="line"><span class="keyword">var</span> iMax = <span class="number">0</span>;</div><div class="line"><span class="keyword">var</span> iIndex = <span class="string">&apos;&apos;</span>;</div><div class="line"><span class="keyword">for</span> (<span class="keyword">var</span> i <span class="keyword">in</span> json) {</div><div class="line">  <span class="keyword">if</span>(json[i]&gt;iMax){</div><div class="line">    iMax = json[i];</div><div class="line">    iIndex = i;</div><div class="line">  }</div><div class="line">}</div><div class="line">alert(<span class="string">&apos;&#x51FA;&#x73B0;&#x6B21;&#x6570;&#x6700;&#x591A;&#x7684;&#x662F;:&apos;</span> + iIndex + <span class="string">&apos;&#x51FA;&#x73B0;&apos;</span> + iMax + <span class="string">&apos;&#x6B21;&apos;</span>);</div></pre></td></tr></table></figure>
<h3 id="&#x5199;&#x4E00;&#x4E2A;&#x83B7;&#x53D6;&#x975E;&#x884C;&#x95F4;&#x6837;&#x5F0F;&#x7684;&#x51FD;&#x6570;"><a href="#&#x5199;&#x4E00;&#x4E2A;&#x83B7;&#x53D6;&#x975E;&#x884C;&#x95F4;&#x6837;&#x5F0F;&#x7684;&#x51FD;&#x6570;" class="headerlink" title="&#x5199;&#x4E00;&#x4E2A;&#x83B7;&#x53D6;&#x975E;&#x884C;&#x95F4;&#x6837;&#x5F0F;&#x7684;&#x51FD;&#x6570;"></a>&#x5199;&#x4E00;&#x4E2A;&#x83B7;&#x53D6;&#x975E;&#x884C;&#x95F4;&#x6837;&#x5F0F;&#x7684;&#x51FD;&#x6570;</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">getStyle</span> (<span class="params">obj, attr, value</span>) </span>{</div><div class="line">  <span class="keyword">if</span>(!value) {</div><div class="line">    <span class="keyword">if</span>(obj.currentStyle) {</div><div class="line">      <span class="keyword">return</span> obj.currentStyle(attr);</div><div class="line">    } <span class="keyword">else</span> {</div><div class="line">      obj.getComputedStyle(attr,<span class="literal">false</span>);</div><div class="line">    }</div><div class="line">  } <span class="keyword">else</span> {</div><div class="line">    obj.style[attr] = value;</div><div class="line">  }</div><div class="line">}</div></pre></td></tr></table></figure>
<h3 id="confirm-&#x786E;&#x8BA4;&#x7528;&#x6237;&#x662F;&#x5426;&#x9000;&#x51FA;&#x5F53;&#x524D;&#x9875;&#x9762;&#xFF0C;&#x786E;&#x8BA4;&#x4E4B;&#x540E;&#x5173;&#x95ED;&#x7A97;"><a href="#confirm-&#x786E;&#x8BA4;&#x7528;&#x6237;&#x662F;&#x5426;&#x9000;&#x51FA;&#x5F53;&#x524D;&#x9875;&#x9762;&#xFF0C;&#x786E;&#x8BA4;&#x4E4B;&#x540E;&#x5173;&#x95ED;&#x7A97;" class="headerlink" title="confirm &#x786E;&#x8BA4;&#x7528;&#x6237;&#x662F;&#x5426;&#x9000;&#x51FA;&#x5F53;&#x524D;&#x9875;&#x9762;&#xFF0C;&#x786E;&#x8BA4;&#x4E4B;&#x540E;&#x5173;&#x95ED;&#x7A97;"></a>confirm &#x786E;&#x8BA4;&#x7528;&#x6237;&#x662F;&#x5426;&#x9000;&#x51FA;&#x5F53;&#x524D;&#x9875;&#x9762;&#xFF0C;&#x786E;&#x8BA4;&#x4E4B;&#x540E;&#x5173;&#x95ED;&#x7A97;</h3><p>&#x8865;&#x5145;&#x6309;&#x94AE;&#x4E8B;&#x4EF6;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x786E;&#x8BA4;&#x7528;&#x6237;&#x662F;&#x5426;&#x9000;&#x51FA;&#x5F53;&#x524D;&#x9875;&#x9762;&#xFF0C;&#x786E;&#x8BA4;&#x4E4B;&#x540E;&#x5173;&#x95ED;&#x7A97;?</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&#x201D;text/javascript&#x201D;</span> &gt;</span><span class="javascript"></span></div><div class="line">  <span class="function"><span class="keyword">function</span> <span class="title">closeWin</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="comment">//&#x5728;&#x6B64;&#x5904;&#x6DFB;&#x52A0;&#x4EE3;&#x7801;</span></div><div class="line">    <span class="keyword">if</span>(confirm(<span class="string">&quot;&#x786E;&#x5B9A;&#x8981;&#x9000;&#x51FA;&#x5417;&#xFF1F;&quot;</span>)){</div><div class="line">      <span class="built_in">window</span>.close(); </div><div class="line">    }</div><div class="line">  }</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&#x201D;button&#x201D;value</span>=<span class="string">&#x201D;&#x5173;&#x95ED;&#x7A97;&#x53E3;&#x201D;onclick</span>=<span class="string">&#x201D;closeWin()&#x201D;/</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x9009;&#x4E2D;&#x5355;&#x9009;&#x6846;"><a href="#&#x9009;&#x4E2D;&#x5355;&#x9009;&#x6846;" class="headerlink" title="&#x9009;&#x4E2D;&#x5355;&#x9009;&#x6846;"></a>&#x9009;&#x4E2D;&#x5355;&#x9009;&#x6846;</h3><p>&#x5B8C;&#x6210;foo()&#x51FD;&#x6570;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x8981;&#x6C42;&#x80FD;&#x591F;&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#x63D0;&#x793A;&#x5F53;&#x524D;&#x9009;&#x4E2D;&#x7684;&#x662F;&#x7B2C;&#x51E0;&#x4E2A;&#x5355;&#x9009;&#x6846;&#x3002;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">metahttp-equiv=&quot;Content-Type&quot;</span> <span class="attr">content</span>=<span class="string">&quot;text/html;charset=utf-8&quot;</span> /&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> &gt;</span><span class="javascript"></span></div><div class="line">  <span class="function"><span class="keyword">function</span> <span class="title">foo</span>(<span class="params"></span>) </span>{</div><div class="line">    <span class="comment">//&#x5728;&#x6B64;&#x5904;&#x6DFB;&#x52A0;&#x4EE3;&#x7801;</span></div><div class="line">    <span class="keyword">var</span> rdo = <span class="built_in">document</span>.form1.radioGroup;</div><div class="line">    <span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; rdo.length; i++) {</div><div class="line">      <span class="keyword">if</span>(rdo.checked) {</div><div class="line">        alert(&#x201C;&#x60A8;&#x9009;&#x62E9;&#x7684;&#x662F;&#x7B2C;&#x201D;+(i+<span class="number">1</span>)+&#x201D;&#x4E2A;&#x5355;&#x9009;&#x6846;&#x201D;);</div><div class="line">      } </div><div class="line">    }</div><div class="line">  }</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">form</span> <span class="attr">name</span>=<span class="string">&quot;form1&quot;</span> &gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;radioGroup&quot;</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;radioGroup&quot;</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;radioGroup&quot;</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;radioGroup&quot;</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">form</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x6839;&#x636E;&#x4E0B;&#x62C9;&#x5217;&#x8868;&#x663E;&#x793A;&#x56FE;&#x7247;"><a href="#&#x6839;&#x636E;&#x4E0B;&#x62C9;&#x5217;&#x8868;&#x663E;&#x793A;&#x56FE;&#x7247;" class="headerlink" title="&#x6839;&#x636E;&#x4E0B;&#x62C9;&#x5217;&#x8868;&#x663E;&#x793A;&#x56FE;&#x7247;"></a>&#x6839;&#x636E;&#x4E0B;&#x62C9;&#x5217;&#x8868;&#x663E;&#x793A;&#x56FE;&#x7247;</h3><p>&#x5B8C;&#x6210;&#x51FD;&#x6570;showImg()&#xFF0C;&#x8981;&#x6C42;&#x80FD;&#x591F;&#x52A8;&#x6001;&#x6839;&#x636E;&#x4E0B;&#x62C9;&#x5217;&#x8868;&#x7684;&#x9009;&#x9879;&#x53D8;&#x5316;&#xFF0C;&#x66F4;&#x65B0;&#x56FE;&#x7247;&#x7684;&#x663E;&#x793A;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> &gt;</span><span class="javascript"></span></div><div class="line">    <span class="function"><span class="keyword">function</span> <span class="title">showImg</span> (<span class="params">oSel</span>) </span>{</div><div class="line">      <span class="comment">//&#x5728;&#x6B64;&#x5904;&#x6DFB;&#x52A0;&#x4EE3;&#x7801; </span></div><div class="line">      <span class="keyword">var</span> str = oSel.value;</div><div class="line">      <span class="built_in">document</span>.getElementById(<span class="string">&quot;pic&quot;</span>).src= str + <span class="string">&quot;.jpg&quot;</span>;</div><div class="line">    }</div><div class="line">  <span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">id</span>=<span class="string">&quot;pic&quot;</span> <span class="attr">src</span>=<span class="string">&quot;img1.jpg&quot;</span> <span class="attr">width</span>=<span class="string">&quot;200&quot;</span> <span class="attr">height</span>=<span class="string">&quot;200&quot;</span> /&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">br</span> /&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">select</span> <span class="attr">id</span>=<span class="string">&quot;sel&quot;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;img1&quot;</span>&gt;</span>&#x57CE;&#x5E02;&#x751F;&#x6D3B;<span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;img2&quot;</span>&gt;</span>&#x90FD;&#x5E02;&#x65E9;&#x62A5;<span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;img3&quot;</span>&gt;</span>&#x9752;&#x5C71;&#x7EFF;&#x6C34;<span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">select</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;"><a href="#&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;" class="headerlink" title="&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;"></a>&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;</h3><p>&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32; abcdefg &#x7684; efg </p>
<p><code>alert(&apos;abcdefg&apos;.substring(4));</code></p>
<h2 id="24&#x3001;&#x7A0B;&#x5E8F;&#x9009;&#x62E9;&#x9898;"><a href="#24&#x3001;&#x7A0B;&#x5E8F;&#x9009;&#x62E9;&#x9898;" class="headerlink" title="24&#x3001;&#x7A0B;&#x5E8F;&#x9009;&#x62E9;&#x9898;"></a>24&#x3001;&#x7A0B;&#x5E8F;&#x9009;&#x62E9;&#x9898;</h2><h3 id="Javascript&#x4E2D;-&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4E00;&#x5B9A;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1F;-BC"><a href="#Javascript&#x4E2D;-&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4E00;&#x5B9A;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1F;-BC" class="headerlink" title="Javascript&#x4E2D;, &#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4E00;&#x5B9A;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1F; ( BC )"></a>Javascript&#x4E2D;, &#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4E00;&#x5B9A;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1F; ( BC )</h3><ul>
<li>A&#x3001;var _&#x53D8;&#x91CF;=NaN;   </li>
<li>B&#x3001;var 0bj = [];   </li>
<li>C&#x3001;var obj = //;    </li>
<li>D&#x3001;var obj = {};</li>
</ul>
<h3 id="&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;-a-&#x548C;-b&#xFF0C;a-b-&#x7684;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;-NaN&#xFF1F;-AC"><a href="#&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;-a-&#x548C;-b&#xFF0C;a-b-&#x7684;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;-NaN&#xFF1F;-AC" class="headerlink" title="&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x53D8;&#x91CF; a &#x548C; b&#xFF0C;a + b &#x7684;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F; NaN&#xFF1F; ( AC )"></a>&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x53D8;&#x91CF; a &#x548C; b&#xFF0C;a + b &#x7684;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F; NaN&#xFF1F; ( AC )</h3><p>A&#x3001;var a=undefined; b=NaN<br>B&#x3001;var a= &#x2018;123&#x2019;; b=NaN<br>C&#x3001;var a =undefined , b =NaN<br>D&#x3001;var a=NaN , b=&#x2019;undefined&#x2019;</p>
<h3 id="var-a-10-b-20-c-4-b-c-a-&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;&#x6B63;&#x786E;&#x7684;&#xFF1F;-B"><a href="#var-a-10-b-20-c-4-b-c-a-&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;&#x6B63;&#x786E;&#x7684;&#xFF1F;-B" class="headerlink" title="var a=10; b=20; c=4;  ++b+c+a++ &#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;&#x6B63;&#x786E;&#x7684;&#xFF1F;( B )"></a>var a=10; b=20; c=4;  ++b+c+a++ &#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x7ED3;&#x679C;&#x662F;&#x6B63;&#x786E;&#x7684;&#xFF1F;( B )</h3><p>A&#x3001;34<br>B&#x3001;35<br>C&#x3001;36<br>D&#x3001;37</p>
<h3 id="&#x8981;&#x5C06;&#x9875;&#x9762;&#x7684;&#x72B6;&#x6001;&#x680F;&#x4E2D;&#x663E;&#x793A;&#x201C;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;&#xFF0C;&#x4E0B;&#x5217;JavaScript&#x8BED;&#x53E5;&#x6B63;&#x786E;&#x7684;&#x662F;-A"><a href="#&#x8981;&#x5C06;&#x9875;&#x9762;&#x7684;&#x72B6;&#x6001;&#x680F;&#x4E2D;&#x663E;&#x793A;&#x201C;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;&#xFF0C;&#x4E0B;&#x5217;JavaScript&#x8BED;&#x53E5;&#x6B63;&#x786E;&#x7684;&#x662F;-A" class="headerlink" title="&#x8981;&#x5C06;&#x9875;&#x9762;&#x7684;&#x72B6;&#x6001;&#x680F;&#x4E2D;&#x663E;&#x793A;&#x201C;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;&#xFF0C;&#x4E0B;&#x5217;JavaScript&#x8BED;&#x53E5;&#x6B63;&#x786E;&#x7684;&#x662F; ( A )"></a>&#x8981;&#x5C06;&#x9875;&#x9762;&#x7684;&#x72B6;&#x6001;&#x680F;&#x4E2D;&#x663E;&#x793A;&#x201C;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;&#xFF0C;&#x4E0B;&#x5217;JavaScript&#x8BED;&#x53E5;&#x6B63;&#x786E;&#x7684;&#x662F; ( A )</h3><p>A. window.status=&#x201D;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;<br>B. document.status=&#x201D;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;<br>C. window.screen=&#x201D;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;<br>D. document.screen=&#x201D;&#x5DF2;&#x7ECF;&#x9009;&#x4E2D;&#x8BE5;&#x6587;&#x672C;&#x6846;&#x201D;</p>
<h3 id="&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1A;-AD"><a href="#&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1A;-AD" class="headerlink" title="&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1A;( AD )"></a>&#x4EE5;&#x4E0B;&#x54EA;&#x6761;&#x8BED;&#x53E5;&#x4F1A;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x9519;&#x8BEF;&#xFF1A;( AD )</h3><p>A.var obj = ();<br>B.var obj = [];<br>C.var obj = {};<br>D.var obj = //;</p>
<h3 id="&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x5355;&#x8BCD;&#x4E0D;&#x5C5E;&#x4E8E;-javascript-&#x4FDD;&#x7559;&#x5B57;&#xFF1A;-B"><a href="#&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x5355;&#x8BCD;&#x4E0D;&#x5C5E;&#x4E8E;-javascript-&#x4FDD;&#x7559;&#x5B57;&#xFF1A;-B" class="headerlink" title="&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x5355;&#x8BCD;&#x4E0D;&#x5C5E;&#x4E8E; javascript &#x4FDD;&#x7559;&#x5B57;&#xFF1A;( B )"></a>&#x4EE5;&#x4E0B;&#x54EA;&#x4E2A;&#x5355;&#x8BCD;&#x4E0D;&#x5C5E;&#x4E8E; javascript &#x4FDD;&#x7559;&#x5B57;&#xFF1A;( B )</h3><p>A.with<br>B.parent<br>C.class<br>D.void</p>
<h3 id="&#x8BF7;&#x9009;&#x62E9;&#x7ED3;&#x679C;&#x4E3A;&#x771F;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;-C"><a href="#&#x8BF7;&#x9009;&#x62E9;&#x7ED3;&#x679C;&#x4E3A;&#x771F;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;-C" class="headerlink" title="&#x8BF7;&#x9009;&#x62E9;&#x7ED3;&#x679C;&#x4E3A;&#x771F;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;( C )"></a>&#x8BF7;&#x9009;&#x62E9;&#x7ED3;&#x679C;&#x4E3A;&#x771F;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;( C )</h3><p>A.null instanceof Object<br>B.null === undefined<br>C.null == undefined<br>D.NaN == NaN</p>
<h2 id="25&#x3001;&#x586B;&#x7A7A;&#x9898;"><a href="#25&#x3001;&#x586B;&#x7A7A;&#x9898;" class="headerlink" title="25&#x3001;&#x586B;&#x7A7A;&#x9898;"></a>25&#x3001;&#x586B;&#x7A7A;&#x9898;</h2><p>Javascript&#x4E2D;, &#x5982;&#x679C;&#x5DF2;&#x77E5;HTML&#x9875;&#x9762;&#x4E2D;&#x7684;&#x67D0;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x7684;id=&#x201D;username&#x201D;&#xFF0C;&#x7528;(&#x2026;)&#x65B9;&#x6CD5;&#x83B7;&#x5F97;&#x8BE5;&#x6807;&#x7B7E;&#x5BF9;&#x8C61;&#x3002;</p>
<blockquote>
<p>document.getElementById(&#x201C;username&#x201D;);</p>
</blockquote>
<p>typeof&#x8FD0;&#x7B97;&#x7B26;&#x8FD4;&#x56DE;&#x503C;&#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x8DDF;javascript&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4E0D;&#x4E00;&#x81F4;&#xFF0C;&#x5B83;&#x662F;(&#x2026;)&#x3002;</p>
<blockquote>
<p>function</p>
</blockquote>
<p>&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x6CA1;&#x6709;&#x4E3A;&#x8BE5;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#xFF0C;&#x5982;&#x679C; alert &#x8BE5;&#x53D8;&#x91CF;&#xFF0C;javascript &#x5F39;&#x51FA;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x4E2D;&#x663E;&#x793A;(&#x2026;)&#x3002;</p>
<blockquote>
<p>undefined</p>
</blockquote>
<h2 id="26&#x3001;&#x5217;&#x4E3E;&#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B;-BOM-&#x91CC;&#x5E38;&#x7528;&#x7684;&#x81F3;&#x5C11;-4-&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x5217;&#x4E3E;-window-&#x5BF9;&#x8C61;&#x7684;&#x5E38;&#x7528;&#x65B9;&#x6CD5;&#x81F3;&#x5C11;-5-&#x4E2A;"><a href="#26&#x3001;&#x5217;&#x4E3E;&#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B;-BOM-&#x91CC;&#x5E38;&#x7528;&#x7684;&#x81F3;&#x5C11;-4-&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x5217;&#x4E3E;-window-&#x5BF9;&#x8C61;&#x7684;&#x5E38;&#x7528;&#x65B9;&#x6CD5;&#x81F3;&#x5C11;-5-&#x4E2A;" class="headerlink" title="26&#x3001;&#x5217;&#x4E3E;&#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B; BOM &#x91CC;&#x5E38;&#x7528;&#x7684;&#x81F3;&#x5C11; 4 &#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x5217;&#x4E3E; window &#x5BF9;&#x8C61;&#x7684;&#x5E38;&#x7528;&#x65B9;&#x6CD5;&#x81F3;&#x5C11; 5 &#x4E2A;"></a>26&#x3001;&#x5217;&#x4E3E;&#x6D4F;&#x89C8;&#x5668;&#x5BF9;&#x8C61;&#x6A21;&#x578B; BOM &#x91CC;&#x5E38;&#x7528;&#x7684;&#x81F3;&#x5C11; 4 &#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x5217;&#x4E3E; window &#x5BF9;&#x8C61;&#x7684;&#x5E38;&#x7528;&#x65B9;&#x6CD5;&#x81F3;&#x5C11; 5 &#x4E2A;</h2><p>&#x5BF9;&#x8C61;&#xFF1A;</p>
<blockquote>
<p>window<br>document<br>location<br>screen<br>history<br>navigator</p>
</blockquote>
<p>&#x65B9;&#x6CD5;&#xFF1A;</p>
<blockquote>
<p>alert()<br>confirm()<br>prompt()<br>open()<br>close()</p>
</blockquote>
<h2 id="27&#x3001;&#x7B80;&#x8FF0;&#x5217;&#x4E3E;&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;-DOM-&#x91CC;-document-&#x7684;&#x5E38;&#x7528;&#x7684;&#x67E5;&#x627E;&#x8BBF;&#x95EE;&#x8282;&#x70B9;&#x7684;&#x65B9;&#x6CD5;&#x5E76;&#x505A;&#x7B80;&#x5355;&#x8BF4;&#x660E;"><a href="#27&#x3001;&#x7B80;&#x8FF0;&#x5217;&#x4E3E;&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;-DOM-&#x91CC;-document-&#x7684;&#x5E38;&#x7528;&#x7684;&#x67E5;&#x627E;&#x8BBF;&#x95EE;&#x8282;&#x70B9;&#x7684;&#x65B9;&#x6CD5;&#x5E76;&#x505A;&#x7B80;&#x5355;&#x8BF4;&#x660E;" class="headerlink" title="27&#x3001;&#x7B80;&#x8FF0;&#x5217;&#x4E3E;&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B; DOM &#x91CC; document &#x7684;&#x5E38;&#x7528;&#x7684;&#x67E5;&#x627E;&#x8BBF;&#x95EE;&#x8282;&#x70B9;&#x7684;&#x65B9;&#x6CD5;&#x5E76;&#x505A;&#x7B80;&#x5355;&#x8BF4;&#x660E;"></a>27&#x3001;&#x7B80;&#x8FF0;&#x5217;&#x4E3E;&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B; DOM &#x91CC; document &#x7684;&#x5E38;&#x7528;&#x7684;&#x67E5;&#x627E;&#x8BBF;&#x95EE;&#x8282;&#x70B9;&#x7684;&#x65B9;&#x6CD5;&#x5E76;&#x505A;&#x7B80;&#x5355;&#x8BF4;&#x660E;</h2><blockquote>
<p>Document.getElementById &#x6839;&#x636E;&#x5143;&#x7D20;id&#x67E5;&#x627E;&#x5143;&#x7D20;<br>Document.getElementByName &#x6839;&#x636E;&#x5143;&#x7D20;name&#x67E5;&#x627E;&#x5143;&#x7D20;<br>Document.getElementTagName &#x6839;&#x636E;&#x6307;&#x5B9A;&#x7684;&#x5143;&#x7D20;&#x540D;&#x67E5;&#x627E;&#x5143;&#x7D20;</p>
</blockquote>
<h2 id="28&#x3001;&#x7B80;&#x8FF0;&#x521B;&#x5EFA;&#x51FD;&#x6570;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;"><a href="#28&#x3001;&#x7B80;&#x8FF0;&#x521B;&#x5EFA;&#x51FD;&#x6570;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;" class="headerlink" title="28&#x3001;&#x7B80;&#x8FF0;&#x521B;&#x5EFA;&#x51FD;&#x6570;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;"></a>28&#x3001;&#x7B80;&#x8FF0;&#x521B;&#x5EFA;&#x51FD;&#x6570;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;</h2><p>&#x7B2C;&#x4E00;&#x79CD;&#xFF08;&#x51FD;&#x6570;&#x58F0;&#x660E;&#xFF09;&#xFF1A; </p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">sum1</span>(<span class="params">num1,num2</span>)</span>{</div><div class="line">   <span class="keyword">return</span> num1+num2;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x7B2C;&#x4E8C;&#x79CD;&#xFF08;&#x51FD;&#x6570;&#x8868;&#x8FBE;&#x5F0F;&#xFF09;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> sum2 = <span class="function"><span class="keyword">function</span>(<span class="params">num1,num2</span>)</span>{</div><div class="line">   <span class="keyword">return</span> num1+num2;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x7B2C;&#x4E09;&#x79CD;&#xFF08;&#x51FD;&#x6570;&#x5BF9;&#x8C61;&#x65B9;&#x5F0F;&#xFF09;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> sum3 = <span class="keyword">new</span> <span class="built_in">Function</span>(<span class="string">&quot;num1&quot;</span>, <span class="string">&quot;num2&quot;</span>, <span class="string">&quot;return num1+num2&quot;</span>);</div></pre></td></tr></table></figure>
<h2 id="29&#x3001;Javascript&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;"><a href="#29&#x3001;Javascript&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;" class="headerlink" title="29&#x3001;Javascript&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;"></a>29&#x3001;Javascript&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x7684;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;</h2><p>1)&#x3001;<code>var obj = {};</code>&#xFF08;&#x4F7F;&#x7528;json&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#xFF09;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> obj = {};</div><div class="line">obj.name = <span class="string">&apos;&#x5F20;&#x4E09;&apos;</span>;</div><div class="line">obj.action = <span class="function"><span class="keyword">function</span> (<span class="params"></span>)</span>{</div><div class="line">  alert(<span class="string">&apos;&#x5403;&#x996D;&apos;</span>);</div><div class="line">};</div></pre></td></tr></table></figure>
<p>2)&#x3001;<code>var obj = new Object();</code>&#xFF08;&#x4F7F;&#x7528;Object&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#xFF09;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> obj = <span class="keyword">new</span> <span class="built_in">Object</span>();</div><div class="line">obj.name = <span class="string">&apos;&#x5F20;&#x4E09;&apos;</span>;</div><div class="line">obj.action = <span class="function"><span class="keyword">function</span> (<span class="params"></span>)</span>{</div><div class="line">    alert(<span class="string">&apos;&#x5403;&#x996D;&apos;</span>);</div><div class="line">};</div></pre></td></tr></table></figure>
<p>3)&#x3001;&#x901A;&#x8FC7;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x3002;</p>
<p>(a)&#x3001;&#x4F7F;&#x7528; this &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5982;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> obj = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">  <span class="keyword">this</span>.name =<span class="string">&apos;&#x5F20;&#x4E09;&apos;</span>;</div><div class="line">  <span class="keyword">this</span>.age = <span class="number">19</span>;</div><div class="line">  <span class="keyword">this</span>.action = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">    alert(<span class="string">&apos;&#x5403;&#x996D;&apos;</span>);</div><div class="line">  };</div><div class="line">}</div></pre></td></tr></table></figure>
<p>(b)&#x3001;&#x4F7F;&#x7528; prototype &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5982;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">obj</span> (<span class="params"></span>)</span>{}</div><div class="line">obj.prototype.name =<span class="string">&apos;&#x5F20;&#x4E09;&apos;</span>;</div><div class="line">obj.prototype.action = <span class="function"><span class="keyword">function</span> (<span class="params"></span>)</span>{</div><div class="line">  alert(<span class="string">&apos;&#x5403;&#x996D;&apos;</span>);</div><div class="line">};</div></pre></td></tr></table></figure>
<p>4)&#x3001;&#x901A;&#x8FC7;Window&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#xFF0C;&#x5982;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">window</span>.name = <span class="string">&apos;&#x5F20;&#x4E09;&apos;</span>;</div><div class="line"><span class="built_in">window</span>.age = <span class="number">19</span>;</div><div class="line"><span class="built_in">window</span>.action = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line"> alert(<span class="string">&apos;&#x5403;&#x996D;&apos;</span>);</div><div class="line">};</div></pre></td></tr></table></figure>
<p>5)&#x3001;&#x4F7F;&#x7528;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x3002;&#x5982;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> str = <span class="keyword">new</span> <span class="built_in">String</span>(<span class="string">&quot;&#x5B9E;&#x4F8B;&#x521D;&#x59CB;&#x5316;String&quot;</span>);</div><div class="line"><span class="keyword">var</span> str1 = <span class="string">&quot;&#x76F4;&#x63A5;&#x8D4B;&#x503C;&#x7684;String&quot;</span>;</div><div class="line"><span class="keyword">var</span> func = <span class="keyword">new</span> <span class="built_in">Function</span>(<span class="string">&quot;x&quot;</span>,<span class="string">&quot;alert(x)&quot;</span>);<span class="comment">//&#x793A;&#x4F8B;&#x521D;&#x59CB;&#x5316;func</span></div><div class="line"><span class="keyword">var</span> obj = <span class="keyword">new</span> <span class="built_in">Object</span>();<span class="comment">//&#x793A;&#x4F8B;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A;Object</span></div></pre></td></tr></table></figure>
<h2 id="30&#x3001;iframe&#x7684;&#x4F18;&#x7F3A;&#x70B9;&#xFF1F;"><a href="#30&#x3001;iframe&#x7684;&#x4F18;&#x7F3A;&#x70B9;&#xFF1F;" class="headerlink" title="30&#x3001;iframe&#x7684;&#x4F18;&#x7F3A;&#x70B9;&#xFF1F;"></a>30&#x3001;iframe&#x7684;&#x4F18;&#x7F3A;&#x70B9;&#xFF1F;</h2><p>&#x4F18;&#x70B9;&#xFF1A;</p>
<blockquote>
<p>&#x89E3;&#x51B3;&#x52A0;&#x8F7D;&#x7F13;&#x6162;&#x7684;&#x7B2C;&#x4E09;&#x65B9;&#x5185;&#x5BB9;&#x5982;&#x56FE;&#x6807;&#x548C;&#x5E7F;&#x544A;&#x7B49;&#x7684;&#x52A0;&#x8F7D;&#x95EE;&#x9898;<br>Security sandbox<br>&#x5E76;&#x884C;&#x52A0;&#x8F7D;&#x811A;&#x672C;</p>
</blockquote>
<p>&#x7F3A;&#x70B9;&#xFF1A;</p>
<blockquote>
<p>iframe&#x4F1A;&#x963B;&#x585E;&#x4E3B;&#x9875;&#x9762;&#x7684;Onload&#x4E8B;&#x4EF6;<br>&#x5373;&#x65F6;&#x5185;&#x5BB9;&#x4E3A;&#x7A7A;&#xFF0C;&#x52A0;&#x8F7D;&#x4E5F;&#x9700;&#x8981;&#x65F6;&#x95F4;<br>&#x6CA1;&#x6709;&#x8BED;&#x610F;</p>
</blockquote>
<h2 id="31&#x3001;Cookie-&#x7F3A;&#x70B9;&#xFF1A;"><a href="#31&#x3001;Cookie-&#x7F3A;&#x70B9;&#xFF1A;" class="headerlink" title="31&#x3001;Cookie &#x7F3A;&#x70B9;&#xFF1A;"></a>31&#x3001;Cookie &#x7F3A;&#x70B9;&#xFF1A;</h2><blockquote>
<p>Cookie&#x6570;&#x91CF;&#x548C;&#x957F;&#x5EA6;&#x7684;&#x9650;&#x5236;&#x3002;&#x6BCF;&#x4E2A;domain&#x6700;&#x591A;&#x53EA;&#x80FD;&#x6709;20&#x6761;cookie&#xFF0C;&#x6BCF;&#x4E2A;cookie&#x957F;&#x5EA6;&#x4E0D;&#x80FD;&#x8D85;&#x8FC7;4KB&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x88AB;&#x622A;&#x6389;&#x3002;<br>&#x5B89;&#x5168;&#x6027;&#x95EE;&#x9898;&#x3002;&#x5982;&#x679C;cookie&#x88AB;&#x4EBA;&#x62E6;&#x622A;&#x4E86;&#xFF0C;&#x90A3;&#x4EBA;&#x5C31;&#x53EF;&#x4EE5;&#x53D6;&#x5F97;&#x6240;&#x6709;&#x7684;session&#x4FE1;&#x606F;&#x3002;&#x5373;&#x4F7F;&#x52A0;&#x5BC6;&#x4E5F;&#x4E0E;&#x4E8B;&#x65E0;&#x8865;&#xFF0C;&#x56E0;&#x4E3A;&#x62E6;&#x622A;&#x8005;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x77E5;&#x9053;cookie&#x7684;&#x610F;&#x4E49;&#xFF0C;&#x4ED6;&#x53EA;&#x8981;&#x539F;&#x6837;&#x8F6C;&#x53D1;cookie&#x5C31;&#x53EF;&#x4EE5;&#x8FBE;&#x5230;&#x76EE;&#x7684;&#x4E86;&#x3002;<br>&#x6709;&#x4E9B;&#x72B6;&#x6001;&#x4E0D;&#x53EF;&#x80FD;&#x4FDD;&#x5B58;&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x4E3A;&#x4E86;&#x9632;&#x6B62;&#x91CD;&#x590D;&#x63D0;&#x4EA4;&#x8868;&#x5355;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5728;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x8BA1;&#x6570;&#x5668;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x628A;&#x8FD9;&#x4E2A;&#x8BA1;&#x6570;&#x5668;&#x4FDD;&#x5B58;&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x8D77;&#x4E0D;&#x5230;&#x4EFB;&#x4F55;&#x4F5C;&#x7528;&#x3002;</p>
</blockquote>
<h2 id="32&#x3001;js&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x54EA;&#x4E9B;"><a href="#32&#x3001;js&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x54EA;&#x4E9B;" class="headerlink" title="32&#x3001;js&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x54EA;&#x4E9B;"></a>32&#x3001;js&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x54EA;&#x4E9B;</h2><blockquote>
<p>defer&#x548C;async<br>&#x52A8;&#x6001;&#x521B;&#x5EFA;DOM&#x65B9;&#x5F0F;&#xFF08;&#x521B;&#x5EFA;script&#xFF0C;&#x63D2;&#x5165;&#x5230;DOM&#x4E2D;&#xFF0C;&#x52A0;&#x8F7D;&#x5B8C;&#x6BD5;&#x540E;callBack&#xFF09;<br>&#x6309;&#x9700;&#x5F02;&#x6B65;&#x8F7D;&#x5165;js</p>
</blockquote>
<h2 id="33&#x3001;documen-write-&#x548C;-innerHTML-&#x7684;&#x533A;&#x522B;"><a href="#33&#x3001;documen-write-&#x548C;-innerHTML-&#x7684;&#x533A;&#x522B;" class="headerlink" title="33&#x3001;documen.write &#x548C; innerHTML &#x7684;&#x533A;&#x522B;"></a>33&#x3001;documen.write &#x548C; innerHTML &#x7684;&#x533A;&#x522B;</h2><blockquote>
<p>document.write &#x53EA;&#x80FD;&#x91CD;&#x7ED8;&#x6574;&#x4E2A;&#x9875;&#x9762;<br>innerHTML &#x53EF;&#x4EE5;&#x91CD;&#x7ED8;&#x9875;&#x9762;&#x7684;&#x4E00;&#x90E8;&#x5206; </p>
</blockquote>
<h2 id="34&#x3001;&#x54EA;&#x4E9B;&#x64CD;&#x4F5C;&#x4F1A;&#x9020;&#x6210;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;"><a href="#34&#x3001;&#x54EA;&#x4E9B;&#x64CD;&#x4F5C;&#x4F1A;&#x9020;&#x6210;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;" class="headerlink" title="34&#x3001;&#x54EA;&#x4E9B;&#x64CD;&#x4F5C;&#x4F1A;&#x9020;&#x6210;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;"></a>34&#x3001;&#x54EA;&#x4E9B;&#x64CD;&#x4F5C;&#x4F1A;&#x9020;&#x6210;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;</h2><blockquote>
<p>&#x5185;&#x5B58;&#x6CC4;&#x6F0F;&#x6307;&#x4EFB;&#x4F55;&#x5BF9;&#x8C61;&#x5728;&#x60A8;&#x4E0D;&#x518D;&#x62E5;&#x6709;&#x6216;&#x9700;&#x8981;&#x5B83;&#x4E4B;&#x540E;&#x4ECD;&#x7136;&#x5B58;&#x5728;&#x3002;<br>&#x5783;&#x573E;&#x56DE;&#x6536;&#x5668;&#x5B9A;&#x671F;&#x626B;&#x63CF;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x8BA1;&#x7B97;&#x5F15;&#x7528;&#x4E86;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x5176;&#x4ED6;&#x5BF9;&#x8C61;&#x7684;&#x6570;&#x91CF;&#x3002;<br>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x5F15;&#x7528;&#x6570;&#x91CF;&#x4E3A; 0&#xFF08;&#x6CA1;&#x6709;&#x5176;&#x4ED6;&#x5BF9;&#x8C61;&#x5F15;&#x7528;&#x8FC7;&#x8BE5;&#x5BF9;&#x8C61;&#xFF09;&#xFF0C;&#x6216;&#x5BF9;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;&#x60DF;&#x4E00;&#x5F15;&#x7528;&#x662F;&#x5FAA;&#x73AF;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;&#x5185;&#x5B58;&#x5373;&#x53EF;&#x56DE;&#x6536;&#x3002;</p>
</blockquote>
<ul>
<li>setTimeout &#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F7F;&#x7528;&#x5B57;&#x7B26;&#x4E32;&#x800C;&#x975E;&#x51FD;&#x6570;&#x7684;&#x8BDD;&#xFF0C;&#x4F1A;&#x5F15;&#x53D1;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;&#x3002;</li>
<li>&#x95ED;&#x5305;</li>
<li>&#x63A7;&#x5236;&#x53F0;&#x65E5;&#x5FD7;</li>
<li>&#x5FAA;&#x73AF;&#xFF08;&#x5728;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x5F7C;&#x6B64;&#x5F15;&#x7528;&#x4E14;&#x5F7C;&#x6B64;&#x4FDD;&#x7559;&#x65F6;&#xFF0C;&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;&#xFF09;</li>
</ul>
<h2 id="35&#x3001;&#x4E8B;&#x4EF6;&#x59D4;&#x6258;&#x662F;&#x4EC0;&#x4E48;"><a href="#35&#x3001;&#x4E8B;&#x4EF6;&#x59D4;&#x6258;&#x662F;&#x4EC0;&#x4E48;" class="headerlink" title="35&#x3001;&#x4E8B;&#x4EF6;&#x59D4;&#x6258;&#x662F;&#x4EC0;&#x4E48;"></a>35&#x3001;&#x4E8B;&#x4EF6;&#x59D4;&#x6258;&#x662F;&#x4EC0;&#x4E48;</h2><blockquote>
<p>&#x5229;&#x7528;&#x4E8B;&#x4EF6;&#x5192;&#x6CE1;&#x7684;&#x539F;&#x7406;&#xFF0C;&#x8BA9;&#x81EA;&#x5DF1;&#x7684;&#x6240;&#x89E6;&#x53D1;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x8BA9;&#x5176;&#x7236;&#x5143;&#x7D20;&#x4EE3;&#x66FF;&#x6267;&#x884C;&#xFF01;</p>
</blockquote>
<h2 id="36&#x3001;&#x95ED;&#x5305;&#x662F;&#x4EC0;&#x4E48;&#xFF0C;&#x6709;&#x4EC0;&#x4E48;&#x7279;&#x6027;&#xFF0C;&#x5BF9;&#x9875;&#x9762;&#x6709;&#x4EC0;&#x4E48;&#x5F71;&#x54CD;"><a href="#36&#x3001;&#x95ED;&#x5305;&#x662F;&#x4EC0;&#x4E48;&#xFF0C;&#x6709;&#x4EC0;&#x4E48;&#x7279;&#x6027;&#xFF0C;&#x5BF9;&#x9875;&#x9762;&#x6709;&#x4EC0;&#x4E48;&#x5F71;&#x54CD;" class="headerlink" title="36&#x3001;&#x95ED;&#x5305;&#x662F;&#x4EC0;&#x4E48;&#xFF0C;&#x6709;&#x4EC0;&#x4E48;&#x7279;&#x6027;&#xFF0C;&#x5BF9;&#x9875;&#x9762;&#x6709;&#x4EC0;&#x4E48;&#x5F71;&#x54CD;"></a>36&#x3001;&#x95ED;&#x5305;&#x662F;&#x4EC0;&#x4E48;&#xFF0C;&#x6709;&#x4EC0;&#x4E48;&#x7279;&#x6027;&#xFF0C;&#x5BF9;&#x9875;&#x9762;&#x6709;&#x4EC0;&#x4E48;&#x5F71;&#x54CD;</h2><blockquote>
<p>&#x95ED;&#x5305;&#x5C31;&#x662F;&#x80FD;&#x591F;&#x8BFB;&#x53D6;&#x5176;&#x4ED6;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x51FD;&#x6570;&#x3002;<br>&#x5728;&#x672C;&#x8D28;&#x4E0A;&#xFF0C;&#x95ED;&#x5305;&#x5C31;&#x662F;&#x5C06;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x548C;&#x51FD;&#x6570;&#x5916;&#x90E8;&#x8FDE;&#x63A5;&#x8D77;&#x6765;&#x7684;&#x4E00;&#x5EA7;&#x6865;&#x6881;&#x3002;</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">outer</span>(<span class="params"></span>)</span>{</div><div class="line">  <span class="keyword">var</span> num = <span class="number">1</span>;</div><div class="line">  <span class="function"><span class="keyword">function</span> <span class="title">inner</span>(<span class="params"></span>)</span>{</div><div class="line">    <span class="keyword">var</span> n = <span class="number">2</span>;</div><div class="line">    alert(n + num);</div><div class="line">  }</div><div class="line">  <span class="keyword">return</span> inner;</div><div class="line">}</div><div class="line">outer()();</div></pre></td></tr></table></figure>
<p><a href="http://blog.csdn.net/gaoshanwudi/article/details/7355794" target="_blank" rel="external">&#x95ED;&#x5305;&#x8D44;&#x6599;</a></p>
<h2 id="37&#x3001;&#x89E3;&#x91CA;-jsonp-&#x7684;&#x539F;&#x7406;&#xFF0C;&#x4EE5;&#x53CA;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x662F;&#x771F;&#x6B63;&#x7684;-ajax"><a href="#37&#x3001;&#x89E3;&#x91CA;-jsonp-&#x7684;&#x539F;&#x7406;&#xFF0C;&#x4EE5;&#x53CA;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x662F;&#x771F;&#x6B63;&#x7684;-ajax" class="headerlink" title="37&#x3001;&#x89E3;&#x91CA; jsonp &#x7684;&#x539F;&#x7406;&#xFF0C;&#x4EE5;&#x53CA;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x662F;&#x771F;&#x6B63;&#x7684; ajax"></a>37&#x3001;&#x89E3;&#x91CA; jsonp &#x7684;&#x539F;&#x7406;&#xFF0C;&#x4EE5;&#x53CA;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x662F;&#x771F;&#x6B63;&#x7684; ajax</h2><blockquote>
<p>&#x52A8;&#x6001;&#x521B;&#x5EFA;script&#x6807;&#x7B7E;&#xFF0C;&#x56DE;&#x8C03;&#x51FD;&#x6570;<br>Ajax&#x662F;&#x9875;&#x9762;&#x65E0;&#x5237;&#x65B0;&#x8BF7;&#x6C42;&#x6570;&#x636E;&#x64CD;&#x4F5C;</p>
</blockquote>
<h2 id="378&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53CD;&#x8F6C;&#xFF0C;&#x5982;&#x5C06;-&#x2018;12345678&#x2019;-&#x53D8;&#x6210;-&#x2018;87654321&#x2019;"><a href="#378&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53CD;&#x8F6C;&#xFF0C;&#x5982;&#x5C06;-&#x2018;12345678&#x2019;-&#x53D8;&#x6210;-&#x2018;87654321&#x2019;" class="headerlink" title="378&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53CD;&#x8F6C;&#xFF0C;&#x5982;&#x5C06; &#x2018;12345678&#x2019; &#x53D8;&#x6210; &#x2018;87654321&#x2019;"></a>378&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53CD;&#x8F6C;&#xFF0C;&#x5982;&#x5C06; &#x2018;12345678&#x2019; &#x53D8;&#x6210; &#x2018;87654321&#x2019;</h2><p>&#x601D;&#x8DEF;&#xFF1A;&#x5148;&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;&#x6570;&#x7EC4; split()&#xFF0C;&#x5229;&#x7528;&#x6570;&#x7EC4;&#x7684;&#x53CD;&#x5E8F;&#x51FD;&#x6570; reverse()&#x98A0;&#x5012;&#x6570;&#x7EC4;&#xFF0C;&#x518D;&#x5229;&#x7528; jion() &#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> str = <span class="string">&apos;12345678&apos;</span>;</div><div class="line">str = str.split(<span class="string">&apos;&apos;</span>).reverse().join(<span class="string">&apos;&apos;</span>);</div></pre></td></tr></table></figure>
<h2 id="39&#x3001;&#x5C06;&#x6570;&#x5B57;-12345678-&#x8F6C;&#x5316;&#x6210;-RMB-&#x5F62;&#x5F0F;-&#x5982;&#xFF1A;-12-345-678"><a href="#39&#x3001;&#x5C06;&#x6570;&#x5B57;-12345678-&#x8F6C;&#x5316;&#x6210;-RMB-&#x5F62;&#x5F0F;-&#x5982;&#xFF1A;-12-345-678" class="headerlink" title="39&#x3001;&#x5C06;&#x6570;&#x5B57; 12345678 &#x8F6C;&#x5316;&#x6210; RMB &#x5F62;&#x5F0F; &#x5982;&#xFF1A; 12,345,678"></a>39&#x3001;&#x5C06;&#x6570;&#x5B57; 12345678 &#x8F6C;&#x5316;&#x6210; RMB &#x5F62;&#x5F0F; &#x5982;&#xFF1A; 12,345,678</h2><p>&#x601D;&#x8DEF;&#xFF1A;&#x5148;&#x5C06;&#x6570;&#x5B57;&#x8F6C;&#x4E3A;&#x5B57;&#x7B26;&#xFF0C; str= str + &#x2018;&#x2019; ;<br>&#x5229;&#x7528;&#x53CD;&#x8F6C;&#x51FD;&#x6570;&#xFF0C;&#x6BCF;&#x4E09;&#x4F4D;&#x5B57;&#x7B26;&#x52A0;&#x4E00;&#x4E2A; &#x2018;,&#x2019;&#x6700;&#x540E;&#x4E00;&#x4F4D;&#x4E0D;&#x52A0;&#xFF1B; re()&#x662F;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x53CD;&#x8F6C;&#x51FD;&#x6570;&#xFF0C;&#x6700;&#x540E;&#x518D;&#x53CD;&#x8F6C;&#x56DE;&#x53BB;&#xFF01;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">re</span>(<span class="params">str</span>) </span>{</div><div class="line">  str += <span class="string">&apos;&apos;</span>;</div><div class="line">  <span class="keyword">return</span> str.split(<span class="string">&quot;&quot;</span>).reverse().join(<span class="string">&quot;&quot;</span>);</div><div class="line">}</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">toRMB</span>(<span class="params">num</span>) </span>{</div><div class="line">  <span class="keyword">var</span> tmp=<span class="string">&apos;&apos;</span>;</div><div class="line">  <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">1</span>; i &lt;= re(num).length; i++) {    </div><div class="line">    tmp += re(num)[i - <span class="number">1</span>];    </div><div class="line">    <span class="keyword">if</span> (i % <span class="number">3</span> == <span class="number">0</span> &amp;&amp; i != re(num).length) {        </div><div class="line">      tmp += <span class="string">&apos;,&apos;</span>;    </div><div class="line">    }</div><div class="line">  }</div><div class="line">  <span class="keyword">return</span> re(tmp);</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="40&#x3001;window-location-search-&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;"><a href="#40&#x3001;window-location-search-&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;" class="headerlink" title="40&#x3001;window.location.search() &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;"></a>40&#x3001;window.location.search() &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;</h2><blockquote>
<p>&#x67E5;&#x8BE2;(&#x53C2;&#x6570;)&#x90E8;&#x5206;&#x3002;<br>&#x9664;&#x4E86;&#x7ED9;&#x52A8;&#x6001;&#x8BED;&#x8A00;&#x8D4B;&#x503C;&#x4EE5;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x540C;&#x6837;&#x53EF;&#x4EE5;&#x7ED9;&#x9759;&#x6001;&#x9875;&#x9762;,&#x5E76;&#x4F7F;&#x7528; javascript &#x6765;&#x83B7;&#x5F97;&#x76F8;&#x4FE1;&#x5E94;&#x7684;&#x53C2;&#x6570;&#x503C;<br>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;?ver=1.0&amp;id=timlq &#x4E5F;&#x5C31;&#x662F;&#x95EE;&#x53F7;&#x540E;&#x9762;&#x7684;&#xFF01;</p>
</blockquote>
<h2 id="41&#x3001;window-location-hash-&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;"><a href="#41&#x3001;window-location-hash-&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;" class="headerlink" title="41&#x3001;window.location.hash &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;"></a>41&#x3001;window.location.hash &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;</h2><blockquote>
<p>&#x951A;&#x70B9; &#x8FD4;&#x56DE;&#x503C;&#xFF1A;#love</p>
</blockquote>
<h2 id="42&#x3001;window-location-reload-&#x4F5C;&#x7528;&#xFF1F;"><a href="#42&#x3001;window-location-reload-&#x4F5C;&#x7528;&#xFF1F;" class="headerlink" title="42&#x3001;window.location.reload() &#x4F5C;&#x7528;&#xFF1F;"></a>42&#x3001;window.location.reload() &#x4F5C;&#x7528;&#xFF1F;</h2><blockquote>
<p>&#x5237;&#x65B0;&#x5F53;&#x524D;&#x9875;&#x9762;</p>
</blockquote>
<h2 id="43&#x3001;Javascript-&#x4E2D;&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF1F;"><a href="#43&#x3001;Javascript-&#x4E2D;&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF1F;" class="headerlink" title="43&#x3001;Javascript &#x4E2D;&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF1F;"></a>43&#x3001;Javascript &#x4E2D;&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF1F;</h2><blockquote>
<p>&#x5728;Javascript&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x4E0D;&#x518D;&#x88AB;&#x5F15;&#x7528;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x5C31;&#x4F1A;&#x88AB;GC&#x56DE;&#x6536;&#x3002;&#x5982;&#x679C;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x4E92;&#x76F8;&#x5F15;&#x7528;&#xFF0C;&#x800C;&#x4E0D;&#x518D;  &#x88AB;&#x7B2C;3&#x8005;&#x6240;&#x5F15;&#x7528;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E24;&#x4E2A;&#x4E92;&#x76F8;&#x5F15;&#x7528;&#x7684;&#x5BF9;&#x8C61;&#x4E5F;&#x4F1A;&#x88AB;&#x56DE;&#x6536;&#x3002;&#x56E0;&#x4E3A;&#x51FD;&#x6570;a&#x88AB;b&#x5F15;&#x7528;&#xFF0C;b&#x53C8;&#x88AB;a&#x5916;&#x7684;c&#x5F15;&#x7528;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;&#x4E3A;&#x4EC0;&#x4E48;  &#x51FD;&#x6570;a&#x6267;&#x884C;&#x540E;&#x4E0D;&#x4F1A;&#x88AB;&#x56DE;&#x6536;&#x7684;&#x539F;&#x56E0;&#x3002; </p>
</blockquote>
<h2 id="44&#x3001;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x80FD;&#x5B9A;&#x4E49;-1px-&#x5DE6;&#x53F3;&#x7684;-div-&#x5BB9;&#x5668;"><a href="#44&#x3001;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x80FD;&#x5B9A;&#x4E49;-1px-&#x5DE6;&#x53F3;&#x7684;-div-&#x5BB9;&#x5668;" class="headerlink" title="44&#x3001;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x80FD;&#x5B9A;&#x4E49; 1px &#x5DE6;&#x53F3;&#x7684; div &#x5BB9;&#x5668;"></a>44&#x3001;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x80FD;&#x5B9A;&#x4E49; 1px &#x5DE6;&#x53F3;&#x7684; div &#x5BB9;&#x5668;</h2><p>IE6&#x4E0B;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x662F;&#x56E0;&#x4E3A;&#x9ED8;&#x8BA4;&#x7684;&#x884C;&#x9AD8;&#x9020;&#x6210;&#x7684;&#xFF0C;&#x89E3;&#x51B3;&#x7684;&#x65B9;&#x6CD5;&#x4E5F;&#x6709;&#x5F88;&#x591A;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<p><code>overflow:hidden</code> | <code>zoom:0.08</code> | <code>line-height:1px</code></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>感谢您的支持！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>打 赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofy7k3v4s.bkt.clouddn.com/wcpayCode.jpg" alt="Hongqin Ma WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofy7k3v4s.bkt.clouddn.com/apayCode.jpg" alt="Hongqin Ma Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/js/" rel="tag">#js</a>
          
            <a href="/tags/题库/" rel="tag">#题库</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/07/12/e001-面试题库-HTML、CSS/" rel="next" title="题库-HTML、CSS篇">
                <i class="fa fa-chevron-left"></i> 题库-HTML、CSS篇
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/07/26/e003-面试题库-js-基础（下）/" rel="prev" title="题库-js 基础（下）">
                题库-js 基础（下） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/07/19/e002-面试题库-js-基础（上）/"
     data-title="题库-js 篇（上）"
     data-content=""
     data-url="https://hongqinma.github.io/2015/07/19/e002-面试题库-js-基础（上）/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/07/19/e002-面试题库-js-基础（上）/"
           data-title="题库-js 篇（上）" data-url="https://hongqinma.github.io/2015/07/19/e002-面试题库-js-基础（上）/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1、javascript-的-typeof-返回哪些数据类型"><span class="nav-number">1.</span> <span class="nav-text">1、javascript 的 typeof 返回哪些数据类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2、3-种强制类型转换和-2-种隐式类型转换"><span class="nav-number">2.</span> <span class="nav-text">2、3 种强制类型转换和 2 种隐式类型转换</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3、split-、join-的区别"><span class="nav-number">3.</span> <span class="nav-text">3、split() 、join() 的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4、数组方法pop-、push-、unshift-、shift"><span class="nav-number">4.</span> <span class="nav-text">4、数组方法pop()、push()、unshift()、shift()</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5、事件绑定和普通事件有什么区别"><span class="nav-number">5.</span> <span class="nav-text">5、事件绑定和普通事件有什么区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6、IE和DOM事件流的区别"><span class="nav-number">6.</span> <span class="nav-text">6、IE和DOM事件流的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7、IE和标准下有哪些兼容性的写法"><span class="nav-number">7.</span> <span class="nav-text">7、IE和标准下有哪些兼容性的写法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8、call、apply和bind的区别"><span class="nav-number">8.</span> <span class="nav-text">8、call、apply和bind的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#函数调用、this指向、返回值"><span class="nav-number">9.</span> <span class="nav-text">函数调用、this指向、返回值</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#函数的-4-种调用模式"><span class="nav-number">9.1.</span> <span class="nav-text">函数的 4 种调用模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#不同调用模式中的this的值"><span class="nav-number">9.2.</span> <span class="nav-text">不同调用模式中的this的值</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#调用模式中的返回值"><span class="nav-number">9.3.</span> <span class="nav-text">调用模式中的返回值</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#9、b-继承-a-的方法"><span class="nav-number">10.</span> <span class="nav-text">9、b 继承 a 的方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10、如何阻止事件冒泡和默认事件"><span class="nav-number">11.</span> <span class="nav-text">10、如何阻止事件冒泡和默认事件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#11、添加、删除、替换、插入到某个接点的方法"><span class="nav-number">12.</span> <span class="nav-text">11、添加、删除、替换、插入到某个接点的方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#12、javascript的本地对象，内置对象和宿主对象"><span class="nav-number">13.</span> <span class="nav-text">12、javascript的本地对象，内置对象和宿主对象</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-window-onload-和-document-ready-的区别"><span class="nav-number">14.</span> <span class="nav-text">13. window.onload 和 document ready 的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#14、”-”-和-“-”-的不同"><span class="nav-number">15.</span> <span class="nav-text">14、”==” 和 “===” 的不同</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#15、javascript的同源策略"><span class="nav-number">16.</span> <span class="nav-text">15、javascript的同源策略</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#16、JavaScript-是一门什么样的语言，它的特点"><span class="nav-number">17.</span> <span class="nav-text">16、JavaScript 是一门什么样的语言，它的特点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#17、JavaScript的数据类型"><span class="nav-number">18.</span> <span class="nav-text">17、JavaScript的数据类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#18-已知-ID-的-Input-输入框，获取这个输入框的输入值，怎么做？"><span class="nav-number">19.</span> <span class="nav-text">18. 已知 ID 的 Input 输入框，获取这个输入框的输入值，怎么做？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#19、获取到页面中所有-checkbox"><span class="nav-number">20.</span> <span class="nav-text">19、获取到页面中所有 checkbox</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#20-设置一个已知-ID-的-DIV-的-html-内容为-xxxx-，字体颜色设置为黑色"><span class="nav-number">21.</span> <span class="nav-text">20. 设置一个已知 ID 的 DIV 的 html 内容为 xxxx ，字体颜色设置为黑色</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#21-当一个-DOM-节点被点击时候能够执行一个函数"><span class="nav-number">22.</span> <span class="nav-text">21. 当一个 DOM 节点被点击时候能够执行一个函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#22-代码题"><span class="nav-number">23.</span> <span class="nav-text">22. 代码题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined、-报错"><span class="nav-number">23.1.</span> <span class="nav-text">undefined、 报错</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#typeof"><span class="nav-number">23.2.</span> <span class="nav-text">typeof</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#“-”-运算符"><span class="nav-number">23.3.</span> <span class="nav-text">“==” 运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#类型转换"><span class="nav-number">23.4.</span> <span class="nav-text">类型转换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#词法作用域"><span class="nav-number">23.5.</span> <span class="nav-text">词法作用域</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1"><span class="nav-number">23.5.1.</span> <span class="nav-text">(1)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2"><span class="nav-number">23.5.2.</span> <span class="nav-text">(2)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3"><span class="nav-number">23.5.3.</span> <span class="nav-text">(3)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4"><span class="nav-number">23.5.4.</span> <span class="nav-text">(4)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5"><span class="nav-number">23.5.5.</span> <span class="nav-text">(5)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1"><span class="nav-number">23.5.6.</span> <span class="nav-text">(5)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6"><span class="nav-number">23.5.7.</span> <span class="nav-text">(6)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7"><span class="nav-number">23.5.8.</span> <span class="nav-text">(7)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-1"><span class="nav-number">23.5.9.</span> <span class="nav-text">(7)</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#引用类型"><span class="nav-number">23.6.</span> <span class="nav-text">引用类型</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-1"><span class="nav-number">23.6.1.</span> <span class="nav-text">(1)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-1"><span class="nav-number">23.6.2.</span> <span class="nav-text">(2)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-1"><span class="nav-number">23.6.3.</span> <span class="nav-text">(3)</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#JS的继承性"><span class="nav-number">23.7.</span> <span class="nav-text">JS的继承性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#精度问题-JS-精度不能精确到-0-1"><span class="nav-number">23.8.</span> <span class="nav-text">精度问题: JS 精度不能精确到 0.1</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#加减运算"><span class="nav-number">23.9.</span> <span class="nav-text">加减运算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#foo-foo-bar"><span class="nav-number">23.10.</span> <span class="nav-text">foo = foo||bar</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#闭包一个例子"><span class="nav-number">23.11.</span> <span class="nav-text">闭包一个例子</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#a-和-a"><span class="nav-number">23.12.</span> <span class="nav-text">++a 和 a++</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#日期函数"><span class="nav-number">23.13.</span> <span class="nav-text">日期函数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数组-concat-方法"><span class="nav-number">23.14.</span> <span class="nav-text">数组 concat() 方法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#23、编程题"><span class="nav-number">24.</span> <span class="nav-text">23、编程题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#计算字符串字节数"><span class="nav-number">24.1.</span> <span class="nav-text">计算字符串字节数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#join"><span class="nav-number">24.2.</span> <span class="nav-text">join()</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#charAt-0-、toUpperCase"><span class="nav-number">24.3.</span> <span class="nav-text">charAt(0)、toUpperCase()</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数组倒排"><span class="nav-number">24.4.</span> <span class="nav-text">数组倒排</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#日期-Date"><span class="nav-number">24.5.</span> <span class="nav-text">日期 Date()</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正则替换"><span class="nav-number">24.6.</span> <span class="nav-text">正则替换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#转义"><span class="nav-number">24.7.</span> <span class="nav-text">转义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#随机数"><span class="nav-number">24.8.</span> <span class="nav-text">随机数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#生成5个不同的随机数；"><span class="nav-number">24.9.</span> <span class="nav-text">生成5个不同的随机数；</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#合并数据并删除某个指定下标元素"><span class="nav-number">24.10.</span> <span class="nav-text">合并数据并删除某个指定下标元素</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#DOM-节点操作"><span class="nav-number">24.11.</span> <span class="nav-text">DOM 节点操作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#URL-解析成-json-对象"><span class="nav-number">24.12.</span> <span class="nav-text">URL 解析成 json 对象</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正则表达式和正则字面量区别"><span class="nav-number">24.13.</span> <span class="nav-text">正则表达式和正则字面量区别</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正则表达式"><span class="nav-number">24.14.</span> <span class="nav-text">正则表达式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#清除字符串前后的空格"><span class="nav-number">24.15.</span> <span class="nav-text">清除字符串前后的空格</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Javascript中-callee-和-caller-的作用"><span class="nav-number">24.16.</span> <span class="nav-text">Javascript中 callee 和 caller 的作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数组去重"><span class="nav-number">24.17.</span> <span class="nav-text">数组去重</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#阶乘函数；"><span class="nav-number">24.18.</span> <span class="nav-text">阶乘函数；</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#判断一个字符串中出现次数最多的字符，统计这个次数"><span class="nav-number">24.19.</span> <span class="nav-text">判断一个字符串中出现次数最多的字符，统计这个次数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#写一个获取非行间样式的函数"><span class="nav-number">24.20.</span> <span class="nav-text">写一个获取非行间样式的函数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#confirm-确认用户是否退出当前页面，确认之后关闭窗"><span class="nav-number">24.21.</span> <span class="nav-text">confirm 确认用户是否退出当前页面，确认之后关闭窗</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#选中单选框"><span class="nav-number">24.22.</span> <span class="nav-text">选中单选框</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#根据下拉列表显示图片"><span class="nav-number">24.23.</span> <span class="nav-text">根据下拉列表显示图片</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#截取字符串"><span class="nav-number">24.24.</span> <span class="nav-text">截取字符串</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#24、程序选择题"><span class="nav-number">25.</span> <span class="nav-text">24、程序选择题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Javascript中-以下哪条语句一定会产生运行错误？-BC"><span class="nav-number">25.1.</span> <span class="nav-text">Javascript中, 以下哪条语句一定会产生运行错误？ ( BC )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#以下两个变量-a-和-b，a-b-的哪个结果是-NaN？-AC"><span class="nav-number">25.2.</span> <span class="nav-text">以下两个变量 a 和 b，a + b 的哪个结果是 NaN？ ( AC )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#var-a-10-b-20-c-4-b-c-a-以下哪个结果是正确的？-B"><span class="nav-number">25.3.</span> <span class="nav-text">var a=10; b=20; c=4;  ++b+c+a++ 以下哪个结果是正确的？( B )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#要将页面的状态栏中显示“已经选中该文本框”，下列JavaScript语句正确的是-A"><span class="nav-number">25.4.</span> <span class="nav-text">要将页面的状态栏中显示“已经选中该文本框”，下列JavaScript语句正确的是 ( A )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#以下哪条语句会产生运行错误：-AD"><span class="nav-number">25.5.</span> <span class="nav-text">以下哪条语句会产生运行错误：( AD )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#以下哪个单词不属于-javascript-保留字：-B"><span class="nav-number">25.6.</span> <span class="nav-text">以下哪个单词不属于 javascript 保留字：( B )</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#请选择结果为真的表达式：-C"><span class="nav-number">25.7.</span> <span class="nav-text">请选择结果为真的表达式：( C )</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#25、填空题"><span class="nav-number">26.</span> <span class="nav-text">25、填空题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#26、列举浏览器对象模型-BOM-里常用的至少-4-个对象，并列举-window-对象的常用方法至少-5-个"><span class="nav-number">27.</span> <span class="nav-text">26、列举浏览器对象模型 BOM 里常用的至少 4 个对象，并列举 window 对象的常用方法至少 5 个</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#27、简述列举文档对象模型-DOM-里-document-的常用的查找访问节点的方法并做简单说明"><span class="nav-number">28.</span> <span class="nav-text">27、简述列举文档对象模型 DOM 里 document 的常用的查找访问节点的方法并做简单说明</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#28、简述创建函数的几种方式"><span class="nav-number">29.</span> <span class="nav-text">28、简述创建函数的几种方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#29、Javascript创建对象的几种方式"><span class="nav-number">30.</span> <span class="nav-text">29、Javascript创建对象的几种方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#30、iframe的优缺点？"><span class="nav-number">31.</span> <span class="nav-text">30、iframe的优缺点？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#31、Cookie-缺点："><span class="nav-number">32.</span> <span class="nav-text">31、Cookie 缺点：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#32、js延迟加载的方式有哪些"><span class="nav-number">33.</span> <span class="nav-text">32、js延迟加载的方式有哪些</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#33、documen-write-和-innerHTML-的区别"><span class="nav-number">34.</span> <span class="nav-text">33、documen.write 和 innerHTML 的区别</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#34、哪些操作会造成内存泄漏"><span class="nav-number">35.</span> <span class="nav-text">34、哪些操作会造成内存泄漏</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#35、事件委托是什么"><span class="nav-number">36.</span> <span class="nav-text">35、事件委托是什么</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#36、闭包是什么，有什么特性，对页面有什么影响"><span class="nav-number">37.</span> <span class="nav-text">36、闭包是什么，有什么特性，对页面有什么影响</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#37、解释-jsonp-的原理，以及为什么不是真正的-ajax"><span class="nav-number">38.</span> <span class="nav-text">37、解释 jsonp 的原理，以及为什么不是真正的 ajax</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#378、字符串反转，如将-‘12345678’-变成-‘87654321’"><span class="nav-number">39.</span> <span class="nav-text">378、字符串反转，如将 ‘12345678’ 变成 ‘87654321’</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#39、将数字-12345678-转化成-RMB-形式-如：-12-345-678"><span class="nav-number">40.</span> <span class="nav-text">39、将数字 12345678 转化成 RMB 形式 如： 12,345,678</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#40、window-location-search-返回的是什么？"><span class="nav-number">41.</span> <span class="nav-text">40、window.location.search() 返回的是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#41、window-location-hash-返回的是什么？"><span class="nav-number">42.</span> <span class="nav-text">41、window.location.hash 返回的是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#42、window-location-reload-作用？"><span class="nav-number">43.</span> <span class="nav-text">42、window.location.reload() 作用？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#43、Javascript-中的垃圾回收机制？"><span class="nav-number">44.</span> <span class="nav-text">43、Javascript 中的垃圾回收机制？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#44、为什么不能定义-1px-左右的-div-容器"><span class="nav-number">45.</span> <span class="nav-text">44、为什么不能定义 1px 左右的 div 容器</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
